From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Bruce Momjian <bruce(at)momjian(dot)us>, Abhijit Menon-Sen <ams(at)oryx(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Allow COMMENT ON to accept an expression rather than just a string |
Date: | 2009-04-11 18:46:23 |
Message-ID: | 162867790904111146p5a632117j6c47e5d28577ab5c@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2009/4/11 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> But the proc
>> CREATE OR REPLACE FUNCTION some_proc(tabname varchar)
>> RETURNS void AS $$
>> BEGIN
>> EXECUTE 'CREATE TABLE $1(a integer)' USING tabname;
>
>> is more readable than EXECUTE 'CREATE TABLE ' || tabname || '(....
>
> I was intentionally excluding the idea of substituting parameters for
> names as opposed to constants. For one thing it's fundamentally
> ambiguous --- given
>
> string_var := 'foo';
>
> EXECUTE 'SELECT $1 FROM bar' USING string_var;
>
> is that supposed to mean SELECT 'foo' FROM bar or SELECT foo FROM bar?
>
> The other problem is that if you allow name substitution it becomes
> entirely impossible to do any planning or even validity checking before
> the parameter values are available. So while string assembly is kind
> of a pain in the rear when you really do need a dynamic name reference,
> I think we should keep it firmly separate from parameter substitution.
>
+1
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | Marko Kreen | 2009-04-11 18:47:39 | Re: Unicode string literals versus the world |
Previous Message | Tom Lane | 2009-04-11 18:44:39 | Re: Allow COMMENT ON to accept an expression rather than just a string |