Re: have you feel anything when you read this ?

From: "Eugene E(dot)" <sad(at)bankir(dot)ru>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: have you feel anything when you read this ?
Date: 2006-04-05 06:34:54
Message-ID: 4433650E.1020508@bankir.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Stephan Szabo wrote:
> On Tue, 4 Apr 2006, Eugene E. wrote:
>
>
>>Stephan Szabo wrote:
>>
>>>On Fri, 31 Mar 2006, Eugene E. wrote:
>>>
>>>
>>>
>>>>Peter Eisentraut wrote:
>>>>
>>>>
>>>>>Eugene E. wrote:
>>>>>
>>>>>
>>>>>
>>>>>>the problem is: you'll get this four byte sequence '\000' _instead_
>>>>>>of NUL-byte anyway.
>>>>>
>>>>>
>>>>>What you seem to be missing is that PostgreSQL data can be represented
>>>>>in textual and in binary form. What you in psql is the textual form.
>>>>>If you want the binary form you need to select it. Then you can pass
>>>>>the exact bytes back and forth.
>>>>
>>>>your sentence is not true.
>>>>I can not select exact bytes even if i use BYTEA type
>>>
>>>
>>>No, that is still using the textual form. If you use PQexecParams and set
>>>the last argument to show you want binary data, you should get binary
>>>data.

ok
then i am using PQexecParams

the following tiny program shows a wonderful lameness...

#include <stdlib.h>
#include <stdio.h>
#include "libpq-fe.h"

int
main (void)
{
PGconn * conn;
PGresult * res;
char * val;
char * l;
int len;

conn = PQconnectdb("user=scott password=tiger name=test_db");

PQexec(conn, "CREATE TABLE t (a BYTEA)");
PQexec(conn, "INSERT INTO t VALUES ('ab\\\\000cd')");

res = PQexecParams(conn, "SELECT a,length(a) FROM t", 0, NULL, NULL,
NULL, NULL, 1);
val = PQgetvalue(res,0,0);
l = PQgetvalue(res,0,1);
len = PQgetlength(res,0,0);
printf("what_we_retrive='screened' its_value_length=%i but
orig_length=%s\n",len,l);

PQclear(res);
PQfinish(conn);

return 0;
}

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jure Kodzoman (Dhimahi) 2006-04-05 11:23:38 GROUP BY issue
Previous Message Richard Broersma Jr 2006-04-05 04:37:32 Re: query to return hourly snapshot