Re: No parameters support in "create user"?

Lists: pgsql-hackers
From: Shachar Shemesh <psql(at)shemesh(dot)biz>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: No parameters support in "create user"?
Date: 2004-09-20 12:04:17
Message-ID: 414EC741.2000506@shemesh.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi list,

When I try to create a user using the "create user" SQL command, where
the command is being executed using the PQexecParams function from
libpq, and the username and password are passed as "text" (oid 0x19)
parameters (binary), I get a syntax error. The command I'm doing is:

create user $1 with encrypted password $2

Any idea why this is not working? Is it supposed to work? Trying to pass
only the password as a parameter does not work either.

Shachar

--
Shachar Shemesh
Lingnu Open Source Consulting ltd.
http://www.lingnu.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Shachar Shemesh <psql(at)shemesh(dot)biz>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: No parameters support in "create user"?
Date: 2004-09-20 14:36:34
Message-ID: 11310.1095690994@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Shachar Shemesh <psql(at)shemesh(dot)biz> writes:
> create user $1 with encrypted password $2

> Any idea why this is not working?

Parameters are only supported in plannable statements
(SELECT/INSERT/UPDATE/DELETE; I think there is some hack for DECLARE
CURSOR these days too).

regards, tom lane


From: Shachar Shemesh <psql(at)shemesh(dot)biz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: No parameters support in "create user"?
Date: 2004-09-20 16:59:41
Message-ID: 414F0C7D.4000306@shemesh.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:

>Parameters are only supported in plannable statements
>(SELECT/INSERT/UPDATE/DELETE; I think there is some hack for DECLARE
>CURSOR these days too).
>
>
That's a shame.

Aside from executing prepared statements, parameters are also useful for
preventing SQL injections. Under those cases, they are useful for all
commands, not only those that can be prepared.

Oh well. I'm not sure whether that's extremely clever or downright
insane, but I'm solving this problem by calling "Select
quote_literal($1)" and "select quote_id($1)", and then using the results.

Shachar

--
Shachar Shemesh
Lingnu Open Source Consulting ltd.
http://www.lingnu.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Shachar Shemesh <psql(at)shemesh(dot)biz>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: No parameters support in "create user"?
Date: 2004-09-20 17:29:01
Message-ID: 12813.1095701341@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Shachar Shemesh <psql(at)shemesh(dot)biz> writes:
> Tom Lane wrote:
>> Parameters are only supported in plannable statements
>> (SELECT/INSERT/UPDATE/DELETE; I think there is some hack for DECLARE
>> CURSOR these days too).

> That's a shame.

> Aside from executing prepared statements, parameters are also useful for
> preventing SQL injections. Under those cases, they are useful for all
> commands, not only those that can be prepared.

Sure. Are you volunteering to fix it?

regards, tom lane


From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: Shachar Shemesh <psql(at)shemesh(dot)biz>
Subject: Re: No parameters support in "create user"?
Date: 2004-09-21 00:49:34
Message-ID: 414F7A9E.3020705@bigfoot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Shachar Shemesh wrote:
> Tom Lane wrote:
>
>> Parameters are only supported in plannable statements
>> (SELECT/INSERT/UPDATE/DELETE; I think there is some hack for DECLARE
>> CURSOR these days too).
>>
>>
> That's a shame.
>
> Aside from executing prepared statements, parameters are also useful for
> preventing SQL injections. Under those cases, they are useful for all
> commands, not only those that can be prepared.
>
> Oh well. I'm not sure whether that's extremely clever or downright
> insane, but I'm solving this problem by calling "Select
> quote_literal($1)" and "select quote_id($1)", and then using the results.

Create your own plpgsql function and call it.

Regards
Gaetano Mendola


From: Shachar Shemesh <psql(at)shemesh(dot)biz>
To: Gaetano Mendola <mendola(at)bigfoot(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: No parameters support in "create user"?
Date: 2004-09-21 06:55:25
Message-ID: 414FD05D.4000505@shemesh.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Gaetano Mendola wrote:

> Shachar Shemesh wrote:
>
>> Tom Lane wrote:
>>
>>> Parameters are only supported in plannable statements
>>> (SELECT/INSERT/UPDATE/DELETE; I think there is some hack for DECLARE
>>> CURSOR these days too).
>>>
>>>
>> That's a shame.
>>
>> Aside from executing prepared statements, parameters are also useful
>> for preventing SQL injections. Under those cases, they are useful for
>> all commands, not only those that can be prepared.
>>
>> Oh well. I'm not sure whether that's extremely clever or downright
>> insane, but I'm solving this problem by calling "Select
>> quote_literal($1)" and "select quote_id($1)", and then using the
>> results.
>
>
> Create your own plpgsql function and call it.

In a way you can say I did `-). This is what I'm using:

http://gborg.postgresql.org/projects/oledb

--
Shachar Shemesh
Lingnu Open Source Consulting ltd.
http://www.lingnu.com/