Re: Going crazy comparing bytea columns

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: scomp(at)canada(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Going crazy comparing bytea columns
Date: 2006-03-01 21:14:46
Message-ID: 20060301211446.GA83071@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Mar 01, 2006 at 10:40:39AM -0800, scomp(at)canada(dot)com wrote:
> I am using npgsql with C# to insert a bytea value into a
> column which will serve as an encrypted password. This works
> well. However, when I retrieve the value, it is different.

Different how? Without knowing more I'd wonder it's a matter of
escaped vs. non-escaped bytea values.

> In other words, "select pwd from table where pwd like @pwd"
> does not work.
>
> Is it not possible to compare bytea columns?

I can't help with npgsql but it's certainly possible to compare
bytea columns. Incidentally, I don't know if this could be causing
any problems, but why are you using LIKE instead of "="?

> NpgsqlCommand cmd = new NpgsqlCommand("select pwd from table
> where usr = @usr and pwd like @pwd",dbConn);

What's the output of the following query?

SELECT pwd, @pwd FROM table WHERE usr = @usr

That should return the value in the database (pwd) and the value
you're providing (@pwd). Let's see how they differ.

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Donald 2006-03-01 21:39:12 Re: [OFFTOPIC] Typo3 + Postgresql anyone?
Previous Message Tom Lane 2006-03-01 21:04:06 Re: Going crazy comparing bytea columns