Lists: | pgsql-hackers |
---|
From: | Reid Thompson <reid(dot)thompson(at)ateb(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | PQescapeBytea v 7.2.3 BUG? |
Date: | 2002-11-11 13:24:44 |
Message-ID: | 3DCFAF9C.6010400@ateb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
should
sprintf(buffer, "%c", 0x5C);
readsz = 1;
buffer2Ptr =(unsigned char *) PQescapeBytea(buffer, readsz, &esclen);
for (ctr = 0; ctr < strlen(buffer2Ptr); ctr++)
{
printf("char[%d] is [%c]\n", ctr, buffer2Ptr[ctr]);
}
printf("esclen is [%d]\n", esclen);
printf("buffer2Ptr is [%s]\n", buffer2Ptr);
result in the following output?
char[0] is [\]
char[1] is [\]
char[2] is [\]
char[3] is [\]
esclen is [5]
buffer2Ptr is [\\\\]
OR should it result in
char[0] is [\]
char[1] is [\]
esclen is [3]
buffer2Ptr is [\\]
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Reid Thompson <reid(dot)thompson(at)ateb(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: PQescapeBytea v 7.2.3 BUG? |
Date: | 2002-11-11 13:38:37 |
Message-ID: | 652.1037021917@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Reid Thompson <reid(dot)thompson(at)ateb(dot)com> writes:
> should
> sprintf(buffer, "%c", 0x5C);
> readsz = 1;
> buffer2Ptr =(unsigned char *) PQescapeBytea(buffer, readsz, &esclen);
> for (ctr = 0; ctr < strlen(buffer2Ptr); ctr++)
> {
> printf("char[%d] is [%c]\n", ctr, buffer2Ptr[ctr]);
> }
> printf("esclen is [%d]\n", esclen);
> printf("buffer2Ptr is [%s]\n", buffer2Ptr);
> result in the following output?
> char[0] is [\]
> char[1] is [\]
> char[2] is [\]
> char[3] is [\]
> esclen is [5]
> buffer2Ptr is [\\\\]
Looks okay to me. Note the 7.2 manual mistakenly claims that esclen
doesn't include the trailing null in the output. According to the
current manual, it does.
regards, tom lane
From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Reid Thompson <reid(dot)thompson(at)ateb(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: PQescapeBytea v 7.2.3 BUG? |
Date: | 2002-11-11 16:43:18 |
Message-ID: | 3DCFDE26.3040705@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Reid Thompson wrote:
> should
[...snip...]
> result in the following output?
>
> char[0] is [\]
> char[1] is [\]
> char[2] is [\]
> char[3] is [\]
> esclen is [5]
> buffer2Ptr is [\\\\]
>
> OR should it result in
> char[0] is [\]
> char[1] is [\]
> esclen is [3]
> buffer2Ptr is [\\]
It should result in the former:
test=# select '\\\\'::bytea as string, length('\\\\'::bytea) as length;
string | length
--------+--------
\\ | 1
(1 row)
HTH,
Joe