Re: [HACKERS] RfD: more powerful any types

2009-09-17 Thread daveg
On Tue, Sep 15, 2009 at 07:38:18AM +0200, Pavel Stehule wrote: it isn't fair :) why you use $$ without single quote? And still this case should be vulnerable on SQL injection. Maybe you or me knows, what SQL injection means, but beginners knows nothing and this people use following bad code:

Re: [HACKERS] RfD: more powerful any types

2009-09-14 Thread decibel
On Sep 14, 2009, at 12:13 AM, Pavel Stehule wrote: 2009/9/13 decibel deci...@decibel.org: On Sep 12, 2009, at 5:54 PM, Andrew Dunstan wrote: decibel wrote: Speaking of concatenation... Something I find sorely missing in plpgsql is the ability to put variables inside of a string, ie:

Re: [HACKERS] RfD: more powerful any types

2009-09-14 Thread Pavel Stehule
2009/9/14 decibel deci...@decibel.org: On Sep 14, 2009, at 12:13 AM, Pavel Stehule wrote: 2009/9/13 decibel deci...@decibel.org: On Sep 12, 2009, at 5:54 PM, Andrew Dunstan wrote: decibel wrote: Speaking of concatenation... Something I find sorely missing in plpgsql is the ability to

Re: [HACKERS] RfD: more powerful any types

2009-09-14 Thread Merlin Moncure
On Mon, Sep 14, 2009 at 1:42 PM, Pavel Stehule pavel.steh...@gmail.com wrote: How is it any worse than what people can already do? Anyone who isn't aware of the dangers of SQL injection has already screwed themselves. You're basically arguing that they would put a variable inside of quotes, but

Re: [HACKERS] RfD: more powerful any types

2009-09-14 Thread Pavel Stehule
2009/9/14 Merlin Moncure mmonc...@gmail.com: On Mon, Sep 14, 2009 at 1:42 PM, Pavel Stehule pavel.steh...@gmail.com wrote: How is it any worse than what people can already do? Anyone who isn't aware of the dangers of SQL injection has already screwed themselves. You're basically arguing that

Re: [HACKERS] RfD: more powerful any types

2009-09-14 Thread decibel
On Sep 14, 2009, at 1:02 PM, Pavel Stehule wrote: 2009/9/14 Merlin Moncure mmonc...@gmail.com: On Mon, Sep 14, 2009 at 1:42 PM, Pavel Stehule pavel.steh...@gmail.com wrote: How is it any worse than what people can already do? Anyone who isn't aware of the dangers of SQL injection has

Re: [HACKERS] RfD: more powerful any types

2009-09-14 Thread Pavel Stehule
2009/9/15 decibel deci...@decibel.org: On Sep 14, 2009, at 1:02 PM, Pavel Stehule wrote: 2009/9/14 Merlin Moncure mmonc...@gmail.com: On Mon, Sep 14, 2009 at 1:42 PM, Pavel Stehule pavel.steh...@gmail.com wrote: How is it any worse than what people can already do? Anyone who isn't aware

Re: [HACKERS] RfD: more powerful any types

2009-09-13 Thread Pavel Stehule
Hello ANY [TYPE] and SAME AS [TYPE OF] are syntactic sugar indeed, but they are much more SQL-like than needing to write any or anyelement(n) as argument type or return type I looked on possibilities in gram.y and I thing, type identifiers ANY TYPE is possible without any problems (this

Re: [HACKERS] RfD: more powerful any types

2009-09-13 Thread Hannu Krosing
On Sun, 2009-09-13 at 21:50 +0200, Pavel Stehule wrote: Hello ANY [TYPE] and SAME AS [TYPE OF] are syntactic sugar indeed, but they are much more SQL-like than needing to write any or anyelement(n) as argument type or return type I looked on possibilities in gram.y and I thing,

Re: [HACKERS] RfD: more powerful any types

2009-09-13 Thread decibel
On Sep 12, 2009, at 5:54 PM, Andrew Dunstan wrote: decibel wrote: Speaking of concatenation... Something I find sorely missing in plpgsql is the ability to put variables inside of a string, ie: DECLARE v_table text := ... v_sql text; BEGIN v_sql := SELECT * FROM $v_table; Of course, I'm

Re: [HACKERS] RfD: more powerful any types

2009-09-13 Thread Pavel Stehule
2009/9/13 decibel deci...@decibel.org: On Sep 12, 2009, at 5:54 PM, Andrew Dunstan wrote: decibel wrote: Speaking of concatenation... Something I find sorely missing in plpgsql is the ability to put variables inside of a string, ie: DECLARE v_table text := ... v_sql text; BEGIN v_sql

Re: [HACKERS] RfD: more powerful any types

2009-09-13 Thread Pavel Stehule
2009/9/13 Hannu Krosing ha...@2ndquadrant.com: On Sun, 2009-09-13 at 21:50 +0200, Pavel Stehule wrote: Hello ANY [TYPE] and SAME AS [TYPE OF] are syntactic sugar indeed, but they are much more SQL-like than needing to write any or anyelement(n) as argument type or return type I

Re: [HACKERS] RfD: more powerful any types

2009-09-12 Thread decibel
On Sep 11, 2009, at 10:19 AM, Robert Haas wrote: On Fri, Sep 11, 2009 at 10:30 AM, Tom Lane t...@sss.pgh.pa.us wrote: Kevin Grittner kevin.gritt...@wicourts.gov writes: I think the main benefit of a sprintf type function for PostgreSQL is in the formatting (setting length, scale, alignment),

Re: [HACKERS] RfD: more powerful any types

2009-09-12 Thread daveg
On Fri, Sep 11, 2009 at 11:43:32AM -0400, Merlin Moncure wrote: If you are going to use printf format codes, which is good and useful being something of a standard, I'd call routine printf (not format) and actually wrap vsnprintf. The format codes in printf have a very specific meaning:

Re: [HACKERS] RfD: more powerful any types

2009-09-12 Thread Andrew Dunstan
decibel wrote: Speaking of concatenation... Something I find sorely missing in plpgsql is the ability to put variables inside of a string, ie: DECLARE v_table text := ... v_sql text; BEGIN v_sql := SELECT * FROM $v_table; Of course, I'm assuming that if it was easy to do that it would

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Aidan Van Dyk
* Alvaro Herrera alvhe...@commandprompt.com [090910 23:32]: Is this really all that hard? I'm thinking it could be implemented by using the real C sprintf underneath, passing one % specifier and its corresponding parameter at a time, coerced to whatever the conversion specifier specifies.

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Hannu Krosing
On Thu, 2009-09-10 at 19:52 +0200, Pavel Stehule wrote: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: Alvaro Herrera alvhe...@commandprompt.com writes: alvherre=# select text_format('% was % at % and said % % times', 'Pavel'::text, 'here'::unknown, now(), row('a','b','c'), '{42}'::int[]);

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Alvaro Herrera
Kevin Grittner escribió: Pavel Stehule pavel.steh...@gmail.com wrote: what is more readable? select 'i=' || i || ', b=' || b || ', c=' || c .. or select format('i=%, b=%, c=%', i, b, c ..) Seriously, those are about dead even for me. The concatenation might have a slight

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Kevin Grittner
Alvaro Herrera alvhe...@commandprompt.com wrote: the format version is a lot better than the || alternative. Well, if you're trying to tell me what is easier for me to read, you're probably wrong. I won't presume to try to tell you what you find easier to read. I think the main benefit of

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Tom Lane
Kevin Grittner kevin.gritt...@wicourts.gov writes: I think the main benefit of a sprintf type function for PostgreSQL is in the formatting (setting length, scale, alignment), not in making concatenation more pretty. Exactly, which is why I'm so distressed that this proposal not only hasn't got

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Tom Lane
Alvaro Herrera alvhe...@commandprompt.com writes: Is this really all that hard? I'm thinking it could be implemented by using the real C sprintf underneath, passing one % specifier and its corresponding parameter at a time, coerced to whatever the conversion specifier specifies. The only

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Robert Haas
On Fri, Sep 11, 2009 at 10:30 AM, Tom Lane t...@sss.pgh.pa.us wrote: Kevin Grittner kevin.gritt...@wicourts.gov writes: I think the main benefit of a sprintf type function for PostgreSQL is in the formatting (setting length, scale, alignment), not in making concatenation more pretty.

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: I like the idea of making concatenation more pretty, quite frankly. No one has really responded to Pavel's contention that this is what to_char() is for. [ shrug... ] I regard this as a prettier replacement for to_char. That thing has got nothing

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Merlin Moncure
On Fri, Sep 11, 2009 at 11:19 AM, Robert Haas robertmh...@gmail.com wrote: On Fri, Sep 11, 2009 at 10:30 AM, Tom Lane t...@sss.pgh.pa.us wrote: Kevin Grittner kevin.gritt...@wicourts.gov writes: I think the main benefit of a sprintf type function for PostgreSQL is in the formatting (setting

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Merlin Moncure
On Fri, Sep 11, 2009 at 10:38 AM, Tom Lane t...@sss.pgh.pa.us wrote: Alvaro Herrera alvhe...@commandprompt.com writes: Is this really all that hard?  I'm thinking it could be implemented by using the real C sprintf underneath, passing one % specifier and its corresponding parameter at a time,

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Tom Lane
Merlin Moncure mmonc...@gmail.com writes: If you are going to use printf format codes, which is good and useful being something of a standard, I'd call routine printf (not format) and actually wrap vsnprintf. The format codes in printf have a very specific meaning: converting native C types

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Merlin Moncure
On Fri, Sep 11, 2009 at 12:11 PM, Tom Lane t...@sss.pgh.pa.us wrote: Merlin Moncure mmonc...@gmail.com writes: If you are going to use printf format codes, which is good and useful being something of a standard, I'd call routine printf (not format) and actually wrap vsnprintf.  The format

Re: [HACKERS] RfD: more powerful any types

2009-09-11 Thread Pavel Stehule
2009/9/11 Tom Lane t...@sss.pgh.pa.us: Merlin Moncure mmonc...@gmail.com writes: If you are going to use printf format codes, which is good and useful being something of a standard, I'd call routine printf (not format) and actually wrap vsnprintf.  The format codes in printf have a very

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Hannu Krosing
On Thu, 2009-09-10 at 08:44 +0300, Hannu Krosing wrote: maybe just let users say what they mean, so first time we have any and if we need more then we say same_as(...) Acutually we could be even more SQL-y and have a more verbose syntax for pseudotypes by extending the grammar CREATE

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Peter Eisentraut
On Wed, 2009-09-09 at 16:31 -0400, Tom Lane wrote: The immediate practical problem is that we don't store a typmod for function argument/result types. I guess we could look into doing that ... I think that functionality could also end up being useful for other types. -- Sent via

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Hannu Krosing ha...@krosing.net: On Thu, 2009-09-10 at 08:44 +0300, Hannu Krosing wrote: maybe just let users say what they mean, so first time we have any and if we need more then we say same_as(...) Acutually we could be even more SQL-y and have a more verbose syntax for

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Kevin Grittner
Robert Haas robertmh...@gmail.com wrote: There are languages much less obscure than Haskell that support passing functions as arguments to other functions, such as C. Or Java, which lets you, for example, pass a Class or Method as an argument, and includes support for generics. I see that

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Alvaro Herrera
Pavel Stehule escribió: Please, try to compile and run sprintf function from attachment There's a minor bug in the comparison to PG_NARGS() inside the loop, fixed in this version. The one problem I have with this is that if the format string does not contain any % (and thus there is no extra

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Tom Lane
Alvaro Herrera alvhe...@commandprompt.com writes: alvherre=# select text_format('% was % at % and said % % times', 'Pavel'::text, 'here'::unknown, now(), row('a','b','c'), '{42}'::int[]); text_format

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread David E. Wheeler
On Sep 10, 2009, at 10:16 AM, Tom Lane wrote: Is that what's being proposed? I think that's what currently works, given the limitations of arrays (variadic arguments) to a single data type. That pretty much sucks --- it's just another way of concatenating some strings. I thought the

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Tom Lane
David E. Wheeler da...@kineticode.com writes: On Sep 10, 2009, at 10:16 AM, Tom Lane wrote: Is that what's being proposed? I think that's what currently works, given the limitations of arrays (variadic arguments) to a single data type. Well, at the very least the parameter markers should

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Tom Lane t...@sss.pgh.pa.us: Alvaro Herrera alvhe...@commandprompt.com writes: alvherre=# select text_format('% was % at % and said % % times', 'Pavel'::text, 'here'::unknown, now(), row('a','b','c'), '{42}'::int[]);                                  text_format

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Tom Lane t...@sss.pgh.pa.us: David E. Wheeler da...@kineticode.com writes: On Sep 10, 2009, at 10:16 AM, Tom Lane wrote: Is that what's being proposed? I think that's what currently works, given the limitations of arrays (variadic arguments) to a single data type. no, in my code

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 David E. Wheeler da...@kineticode.com: On Sep 10, 2009, at 10:16 AM, Tom Lane wrote: Is that what's being proposed? I think that's what currently works, given the limitations of arrays (variadic arguments) to a single data type. That pretty much sucks --- it's just another way

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: On Sep 10, 2009, at 10:16 AM, Tom Lane wrote: I thought the idea was to provide the same power as sprintf, eg field width controls, numeric formatting options, etc. no - we have to_char function, why we need different formatting system? Why do

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread David E. Wheeler
On Sep 10, 2009, at 11:16 AM, Tom Lane wrote: no - we have to_char function, why we need different formatting system? Why do we need this at all, when we have the concatenation operator? I think the point of it is that people are used to how sprintf works. So it should work as nearly like

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Robert Haas
On Wed, Sep 9, 2009 at 3:44 PM, Pavel Stehule pavel.steh...@gmail.com wrote: Really, I think we need a type system that doesn't try to represent every type as a 32-bit integer.  Right now, for example, there's no reasonable way to write a function that takes another function as an argument.  

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: On Sep 10, 2009, at 10:16 AM, Tom Lane wrote: I thought the idea was to provide the same power as sprintf, eg field width controls, numeric formatting options, etc. no - we have to_char function, why we

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Robert Haas robertmh...@gmail.com: On Wed, Sep 9, 2009 at 3:44 PM, Pavel Stehule pavel.steh...@gmail.com wrote: Really, I think we need a type system that doesn't try to represent every type as a 32-bit integer.  Right now, for example, there's no reasonable way to write a function

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: The major downside of such a system is that every place where we now count on being able to store a type in a fixed-size field would need to be touched. I don't believe that the overall slowdown in parsing time would be significant, but I do think it

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Kevin Grittner
Pavel Stehule pavel.steh...@gmail.com wrote: what is more readable? select 'i=' || i || ', b=' || b || ', c=' || c .. or select format('i=%, b=%, c=%', i, b, c ..) Seriously, those are about dead even for me. The concatenation might have a slight edge, particularly since I have the

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: I think the point of it is that people are used to how sprintf works. So it should work as nearly like sprintf as possible. How sprintf will be print bytea type, or char(n) type values? Well, that's why it

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: I think the point of it is that people are used to how sprintf works. So it should work as nearly like sprintf as possible. How sprintf will be print bytea type, or

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Robert Haas
On Thu, Sep 10, 2009 at 2:42 PM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: The major downside of such a system is that every place where we now count on being able to store a type in a fixed-size field would need to be touched.  I don't believe that the

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: I think the point of it is that people are used to how sprintf works. So it should work as nearly like sprintf as possible. How sprintf will be print bytea type, or

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: I don't afraid about crashing. Simply I have not idea what sql sprintf's behave in case: SELECT sprintf('some %s', 10) That one I don't think is hard --- coerce the input type to text and print the string. SELECT sprintf('some %d',

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Tom Lane
Robert Haas robertmh...@gmail.com writes: On Thu, Sep 10, 2009 at 2:42 PM, Tom Lane t...@sss.pgh.pa.us wrote: 2. Come up with some way to do the equivalent of variadic any[], ie, a variable number of not-all-the-same-type arguments.  (This isn't just a type-system problem, there's also the

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
good analyse, thank you 2009/9/10 Tom Lane t...@sss.pgh.pa.us: Robert Haas robertmh...@gmail.com writes: The major downside of such a system is that every place where we now count on being able to store a type in a fixed-size field would need to be touched.  I don't believe that the overall

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Tom Lane
Pavel Stehule pavel.steh...@gmail.com writes: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: 1. Allow the existing any pseudotype as an input argument type for PLs. (AFAICS this is simple and painless; about the only question is whether we want to keep using the name any, which because of conflicting

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: 1. Allow the existing any pseudotype as an input argument type for PLs. (AFAICS this is simple and painless; about the only question is whether we want to keep using the

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Robert Haas
On Thu, Sep 10, 2009 at 3:15 PM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: On Thu, Sep 10, 2009 at 2:42 PM, Tom Lane t...@sss.pgh.pa.us wrote: 2. Come up with some way to do the equivalent of variadic any[], ie, a variable number of not-all-the-same-type

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: I don't afraid about crashing. Simply I have not idea what sql sprintf's behave in case: SELECT sprintf('some %s', 10) That one I don't think is hard --- coerce the input type to text and print the string.

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Tom Lane
Hannu Krosing ha...@2ndquadrant.com writes: On Thu, 2009-09-10 at 15:06 -0400, Robert Haas wrote: It might be possible to make it work, but it's likely to create a lot of bloat in pg_type, and will make it very difficult to implement features such as anonymous functions (i.e. LAMBDA). For

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Hannu Krosing
On Thu, 2009-09-10 at 21:30 +0200, Pavel Stehule wrote: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: 1. Allow the existing any pseudotype as an input argument type for PLs. (AFAICS this is simple and painless;

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Hannu Krosing
On Thu, 2009-09-10 at 21:35 +0200, Pavel Stehule wrote: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: I don't afraid about crashing. Simply I have not idea what sql sprintf's behave in case: SELECT sprintf('some %s', 10) That one I don't think

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread David E. Wheeler
On Sep 10, 2009, at 12:10 PM, Tom Lane wrote: SELECT sprintf('some %d', 10::mycustomtype) For the formats that presume an integer or float input in C, perhaps we could coerce to numeric (failing if that fails) and then print appropriately. Or maybe int or float8 would be more appropriate

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Hannu Krosing ha...@krosing.net: On Thu, 2009-09-10 at 21:30 +0200, Pavel Stehule wrote: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: 1. Allow the existing any pseudotype as an input argument type for

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Hannu Krosing ha...@2ndquadrant.com: On Thu, 2009-09-10 at 21:35 +0200, Pavel Stehule wrote: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: I don't afraid about crashing. Simply I have not idea what sql sprintf's behave in case: SELECT

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
There is actualised version, for people who are interested on it. Minimally it should be sample of variadic any function for playing. Don't afraid, I don't plan to send it to commit fest. regards Pavel 2009/9/10 Alvaro Herrera alvhe...@commandprompt.com: Pavel Stehule escribió: Please, try to

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Dimitri Fontaine
Hannu Krosing ha...@2ndquadrant.com writes: 5. Various syntactic sugar to substitute for anyelement. (Not in favor of this myself, it seems to just complicate matters.) I agree; I don't think this solves any real problem. agreed, it does not solve the underlying problem, just may make it

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Hannu Krosing
On Thu, 2009-09-10 at 22:15 +0200, Pavel Stehule wrote: 2009/9/10 Hannu Krosing ha...@2ndquadrant.com: On Thu, 2009-09-10 at 21:35 +0200, Pavel Stehule wrote: 2009/9/10 Tom Lane t...@sss.pgh.pa.us: Pavel Stehule pavel.steh...@gmail.com writes: I don't afraid about crashing. Simply I

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Aidan Van Dyk
* Pavel Stehule pavel.steh...@gmail.com [090910 16:16]: first is coming from C and has C semantic - there is only one possible tag (without binary compatible types) - you cannot use %s for numbers, and %d for strings is some specific value. sprintf(%d, 10) - show address of static string

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Hannu Krosing
On Thu, 2009-09-10 at 15:49 -0400, Tom Lane wrote: Hannu Krosing ha...@2ndquadrant.com writes: On Thu, 2009-09-10 at 15:06 -0400, Robert Haas wrote: It might be possible to make it work, but it's likely to create a lot of bloat in pg_type, and will make it very difficult to implement

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Dimitri Fontaine dfonta...@hi-media.com: Hannu Krosing ha...@2ndquadrant.com writes: 5. Various syntactic sugar to substitute for anyelement.  (Not in favor of this myself, it seems to just complicate matters.) I agree; I don't think this solves any real problem. agreed, it does

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Robert Haas
On Thu, Sep 10, 2009 at 4:38 PM, Hannu Krosing ha...@2ndquadrant.com wrote: On Thu, 2009-09-10 at 15:49 -0400, Tom Lane wrote: Hannu Krosing ha...@2ndquadrant.com writes: On Thu, 2009-09-10 at 15:06 -0400, Robert Haas wrote: It might be possible to make it work, but it's likely to create a

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Robert Haas
On Thu, Sep 10, 2009 at 4:43 PM, Pavel Stehule pavel.steh...@gmail.com wrote: 2009/9/10 Dimitri Fontaine dfonta...@hi-media.com: Hannu Krosing ha...@2ndquadrant.com writes: 5. Various syntactic sugar to substitute for anyelement.  (Not in favor of this myself, it seems to just complicate

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Hannu Krosing
On Thu, 2009-09-10 at 16:48 -0400, Robert Haas wrote: On Thu, Sep 10, 2009 at 4:38 PM, Hannu Krosing ha...@2ndquadrant.com wrote: On Thu, 2009-09-10 at 15:49 -0400, Tom Lane wrote: Hannu Krosing ha...@2ndquadrant.com writes: On Thu, 2009-09-10 at 15:06 -0400, Robert Haas wrote: It might

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Robert Haas robertmh...@gmail.com: On Thu, Sep 10, 2009 at 4:43 PM, Pavel Stehule pavel.steh...@gmail.com wrote: 2009/9/10 Dimitri Fontaine dfonta...@hi-media.com: Hannu Krosing ha...@2ndquadrant.com writes: 5. Various syntactic sugar to substitute for anyelement.  (Not in favor

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/10 Hannu Krosing ha...@2ndquadrant.com: On Thu, 2009-09-10 at 16:48 -0400, Robert Haas wrote: On Thu, Sep 10, 2009 at 4:38 PM, Hannu Krosing ha...@2ndquadrant.com wrote: On Thu, 2009-09-10 at 15:49 -0400, Tom Lane wrote: Hannu Krosing ha...@2ndquadrant.com writes: On Thu,

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Hannu Krosing
On Thu, 2009-09-10 at 15:06 -0400, Robert Haas wrote: On Thu, Sep 10, 2009 at 2:42 PM, Tom Lane t...@sss.pgh.pa.us wrote: Robert Haas robertmh...@gmail.com writes: The major downside of such a system is that every place where we now count on being able to store a type in a fixed-size field

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread David E. Wheeler
On Sep 10, 2009, at 2:08 PM, Hannu Krosing wrote: Perhaps you should try changing ANY to a non-reserved word in the parser and see what happens. If you come up with a way to resolve the shift/reduce and/or reduce/reduce conflicts that will probably result, submit a patch. I don't want

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Robert Haas
On Thu, Sep 10, 2009 at 5:08 PM, Hannu Krosing ha...@2ndquadrant.com wrote: On Thu, 2009-09-10 at 16:48 -0400, Robert Haas wrote: On Thu, Sep 10, 2009 at 4:38 PM, Hannu Krosing ha...@2ndquadrant.com wrote: On Thu, 2009-09-10 at 15:49 -0400, Tom Lane wrote: Hannu Krosing ha...@2ndquadrant.com

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Alvaro Herrera
Aidan Van Dyk escribió: Just to make the task that much harder, if PostgreSQL is going to have a sprintf (in core, or contrib), I *really* hope it's a real sprintf, supporting everything, like: $m positional notation * width argument All the flags [#0- +'] (I as a bonus) field

Re: [HACKERS] RfD: more powerful any types

2009-09-10 Thread Pavel Stehule
2009/9/11 Alvaro Herrera alvhe...@commandprompt.com: Aidan Van Dyk escribió: Just to make the task that much harder, if PostgreSQL is going to have a sprintf (in core, or contrib), I *really* hope it's a real sprintf, supporting everything, like:    $m positional notation    * width

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Peter Eisentraut
On Tue, 2009-09-08 at 10:23 -0700, David E. Wheeler wrote: On Sep 8, 2009, at 10:15 AM, Tom Lane wrote: arg_a IS DISTINCT FROM arg_b Surely you'd want arg_a and arg_b constrained to the same type, otherwise there is no certainty that that means anything at all. Yes, for the

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Alvaro Herrera
Peter Eisentraut wrote: On Tue, 2009-09-08 at 10:23 -0700, David E. Wheeler wrote: On Sep 8, 2009, at 10:15 AM, Tom Lane wrote: arg_a IS DISTINCT FROM arg_b Surely you'd want arg_a and arg_b constrained to the same type, otherwise there is no certainty that that means

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Peter Eisentraut
On Wed, 2009-09-09 at 07:47 -0400, Alvaro Herrera wrote: Peter Eisentraut wrote: On Tue, 2009-09-08 at 10:23 -0700, David E. Wheeler wrote: On Sep 8, 2009, at 10:15 AM, Tom Lane wrote: arg_a IS DISTINCT FROM arg_b Surely you'd want arg_a and arg_b constrained to the same

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Tom Lane
Peter Eisentraut pete...@gmx.net writes: Well, so far we've only seen use cases in this thread that either already work or that are not well-defined. ;-) Well, yeah, the question is can we extract a clear TODO item here. I think there are two somewhat orthogonal issues: 1. Is a completely

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Pavel Stehule
2009/9/9 Tom Lane t...@sss.pgh.pa.us: Peter Eisentraut pete...@gmx.net writes: Well, so far we've only seen use cases in this thread that either already work or that are not well-defined. ;-) Well, yeah, the question is can we extract a clear TODO item here. I think there are two somewhat

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread David E. Wheeler
On Sep 9, 2009, at 6:39 AM, Tom Lane wrote: 1. Is a completely unconstrained argument type (ie any) of any real use to PL functions, and if so how can we expose that usefulness? The only clear thing to do with such an argument is IS NULL/IS NOT NULL tests, which might or might not be worth

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread decibel
On Sep 9, 2009, at 8:39 AM, Tom Lane wrote: Peter Eisentraut pete...@gmx.net writes: Well, so far we've only seen use cases in this thread that either already work or that are not well-defined. ;-) Well, yeah, the question is can we extract a clear TODO item here. I think there are two

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Tom Lane
David E. Wheeler da...@kineticode.com writes: On Sep 9, 2009, at 6:39 AM, Tom Lane wrote: 1. Is a completely unconstrained argument type (ie any) of any real use to PL functions, and if so how can we expose that usefulness? The only clear thing to do with such an argument is IS NULL/IS NOT

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread David E. Wheeler
On Sep 9, 2009, at 10:04 AM, Tom Lane wrote: Well, yeah: it looks like a fertile source of security holes, not to mention implementation difficulties (plpgsql really wants well-typed expressions...). What you can do at the C level is not necessarily sane to give to PL authors. I'm willing to

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Alvaro Herrera
Tom Lane wrote: In an example like create function foo (anyelement, anyelement2, anyelement2) returns anyarray2 the second and third arguments would be tied to be of the same type, and the result would be an array of that type; whereas the first argument's type is unrelated.

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Tom Lane
Alvaro Herrera alvhe...@commandprompt.com writes: Another possible example is sprintf: create function sprintf(text, anyelement, anyelement2, anyelement3, ...) returns text In order for this to work in general, we'd need FUNC_MAX_ARGS different types, which is currently defined as 100 in

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread David E. Wheeler
On Sep 9, 2009, at 10:15 AM, Tom Lane wrote: In order for this to work in general, we'd need FUNC_MAX_ARGS different types, which is currently defined as 100 in our code. But here, any would work perfectly fine, since there's no need for any two arguments to be tied to each other or the

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Tom Lane
David E. Wheeler da...@kineticode.com writes: On Sep 9, 2009, at 10:04 AM, Tom Lane wrote: Well, yeah: it looks like a fertile source of security holes, not to mention implementation difficulties (plpgsql really wants well-typed expressions...). What you can do at the C level is not

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Tom Lane
David E. Wheeler da...@kineticode.com writes: On Sep 9, 2009, at 10:15 AM, Tom Lane wrote: But here, any would work perfectly fine, since there's no need for any two arguments to be tied to each other or the result. Well, only if you write your functions in C. I'd like to be able to write

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Alvaro Herrera
Tom Lane wrote: Alvaro Herrera alvhe...@commandprompt.com writes: Another possible example is sprintf: create function sprintf(text, anyelement, anyelement2, anyelement3, ...) returns text In order for this to work in general, we'd need FUNC_MAX_ARGS different types, which is

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread David E. Wheeler
On Sep 9, 2009, at 10:17 AM, Tom Lane wrote: Well, none, *if* it's defined to have exactly the same runtime behavior as anyelement does. It sounded like you were arguing for something looser. We could certainly define it as being just like anyelement but not constrained to match any other

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Tom Lane
Alvaro Herrera alvhe...@commandprompt.com writes: BTW does any match other pseudotypes? Would I be able to pass a cstring into any? That would create a large security hole I think. How so? 'Cause you can do that now with anyelement. cstring is only a pseudotype for historical reasons,

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread David E. Wheeler
On Sep 9, 2009, at 10:22 AM, Tom Lane wrote: Well, only if you write your functions in C. I'd like to be able to write sprintf() in PL/pgSQL. Or PL/Perl, for that matter. I think you're confusing the point with a secondary issue, which is what access we provide to these pseudotypes in PLs.

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Tom Lane
David E. Wheeler da...@kineticode.com writes: Yes, that sounds about right. Is that not basically what Alvaro was looking for to start with? And is there an any array that could work for variadic functions like sprintf(), as well? Well, no, because arrays are inherently all the same

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Pavel Stehule
2009/9/9 David E. Wheeler da...@kineticode.com: On Sep 9, 2009, at 10:17 AM, Tom Lane wrote: Well, none, *if* it's defined to have exactly the same runtime behavior as anyelement does.  It sounded like you were arguing for something looser.  We could certainly define it as being just like

Re: [HACKERS] RfD: more powerful any types

2009-09-09 Thread Pavel Stehule
2009/9/9 Tom Lane t...@sss.pgh.pa.us: David E. Wheeler da...@kineticode.com writes: Yes, that sounds about right. Is that not basically what Alvaro was looking for to start with? And is there an any array that could work for variadic functions like sprintf(), as well? Well, no, because

  1   2   >