Re: have you feel anything when you read this ? - Mailing list pgsql-sql

From Eugene E.
Subject Re: have you feel anything when you read this ?
Date
Msg-id 442CC95C.1030700@bankir.ru
Whole thread Raw
In response to Re: have you feel anything when you read this ?  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: have you feel anything when you read this ?
List pgsql-sql
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

the folloiwing tiny C-program shows this pretty clear

#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 dbname=test_db");
  PQexec(conn, "CREATE TABLE t (a BYTEA)");  PQexec(conn, "INSERT INTO t VALUES ('ab\\\\000cd')");

  res = PQexec(conn, "SELECT a,length(a) FROM t");  val = PQgetvalue(res,0,0);  l   = PQgetvalue(res,0,1);  len =
PQgetlength(res,0,0); printf("what_we_retrive='%s' its_value_length=%i but 
 
orig_length=%s\n",val,len,l);
  PQclear(res);  PQfinish(conn);
  return 0; }


pgsql-sql by date:

Previous
From: Achilleus Mantzios
Date:
Subject: Re: Ugly group by problem
Next
From: Stephan Szabo
Date:
Subject: Re: have you feel anything when you read this ?