Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UfCGz-00066m-30 for pgsql-interfaces@arkaria.postgresql.org; Wed, 22 May 2013 16:52:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UfCGy-0001Ym-BI for pgsql-interfaces@arkaria.postgresql.org; Wed, 22 May 2013 16:52:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UfCGx-0001Yg-AR for pgsql-interfaces@postgresql.org; Wed, 22 May 2013 16:52:19 +0000 Received: from nm29-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.166]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UfCGq-000219-SF for pgsql-interfaces@postgresql.org; Wed, 22 May 2013 16:52:18 +0000 Received: from [98.139.212.144] by nm29.bullet.mail.bf1.yahoo.com with NNFMP; 22 May 2013 16:52:11 -0000 Received: from [98.139.215.228] by tm1.bullet.mail.bf1.yahoo.com with NNFMP; 22 May 2013 16:52:11 -0000 Received: from [127.0.0.1] by omp1068.mail.bf1.yahoo.com with NNFMP; 22 May 2013 16:52:11 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 23367.69771.bm@omp1068.mail.bf1.yahoo.com Received: (qmail 69601 invoked by uid 60001); 22 May 2013 16:52:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1369241530; bh=pmmts/PJc9/x4rEd2clEJWmLfuA43F3piMCjAOY6OG4=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=l/ThlHMh/QvCDJFfddMLnCTnTcn8aQNtXM7N1XMhIHd9EdWnX4NJ9aE6xJYsZsS5LRWWLV2pBMvJyF+xtp7k75n0Zbpf+qDTLLmRJWqPw0o7F8YUfDTcsFroyBoJuD2vPl82haEGHY8+LvljdfV4gH6VsxqAG5CZA0isQsiDtEo= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:Message-ID:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=5g63tsk/RQJrGOxUgzjOkBp74jIRS1vQVbleI0KFMxQkFi4EOYEjcWYM7gIaEJLlQ5wJdGrVT/QXTL6iKM4pMkPM7Vl5TYmHhD3Id2EKuItpJSh6KqamiIV1+OYlAO64alq/np8QVRLKC+DfkUBKGrTPDRU83uHxDPcJBP4rtqE=; X-YMail-OSG: 9QR3QT0VM1kw0XTltZC0xTEiSblzYvjt8O1.FlBB9kSFDxE wJ10HsJp06khwDK3a3LndGOk7NEeO1EM1sR.faRhunjEo5IXG65xalcXsZmC gSOJYsIbbjnFM7DyTtjJN1QaRoe3YilawxEevjO932CnWuan6dyuh4O1ZLId Os1i949n4GYNX8lpd58JJesZhBOG0ctYdAkTy3iYBd42l1nmnwDepbQzA8SP tDxCZcLRpgT_fuTII2eeW1i1kq8XzxD3P1kXM2tg_1i4hnskpBBofRSrN3eg Ep3mCqKs7DgkK32G1bymjcwhUyT701ppmVTEBDe4RmCyF4Km9ySY_T9aFguu NIbURYhH3Sz9H3gyhaUQzu.tEpAeRF57_WhJP9ifolfrKYa5WuIfQ1J0tIEi 6JTsyr.FIjBpw9RXhPLTgds3r_7QNNYF0FqslpMS1uKnxrRiwGz4T0Tqjz58 R2sSQLesRYDCGMoSgNxX9T2W3hCtM46D_DMSWAS5_ZYVhxCq4G65fo52mnvG kT1Y- Received: from [71.168.162.74] by web164901.mail.bf1.yahoo.com via HTTP; Wed, 22 May 2013 09:52:10 PDT X-Rocket-MIMEInfo: 002.001, SGksCgpJIGZvcmdvdCB0byBtZW50aW9uIHRoYXQgSSdtIHRyeWluZyB0byB1c2UgYmluYXJ5IGRhdGEgZm9ybWF0LgpJIGZvdW5kIGV4YW5wbGVzIG9mIHNlbmRpbmcgc3RyaW5nIGZvcm5hdHRlZCBkYXRlIHRpbWUuIEhvd2V2ZXIsIGkgYW0gYXNzdW1pbmcgdGhlcmUgYXJlIGZ1bmN0aW9ucyB0byBjb3ZlcnQgdW5peCB0aW1lIHRvIHBndGltZXN0YW1wdHogYW5kIG1heSBiZSBmYXN0ZXIKTG9va2luZyBmb3IgaW52ZXJzZSBvZiB0cy5lcG9jaAoKSSBjYW4gYnlwYXNzIGJpdHdpc2UgZnVlbGQgaXNzdWUgYnkBMAEBAQE- X-Mailer: YahooMailAndroidMobile/2.5.2 YahooMailWebService/0.8.142.542 Message-ID: <1369241530.69063.YahooMailAndroidMobile@web164901.mail.bf1.yahoo.com> Date: Wed, 22 May 2013 09:52:10 -0700 (PDT) From: Neeraj Rai Subject: Re: - pgaql binary data date time fornats To: "pgsql-interfaces@postgresql.org" , Neeraj Rai In-Reply-To: <1369185968.87888.YahooMailNeo@web164906.mail.bf1.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-1210131807-1425509699-1369241530=:69063" X-Pg-Spam-Score: -3.1 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-interfaces Precedence: bulk Sender: pgsql-interfaces-owner@postgresql.org ---1210131807-1425509699-1369241530=:69063 Content-Type: text/plain; charset=us-ascii Hi, I forgot to mention that I'm trying to use binary data format. I found exanples of sending string fornatted date time. However, i am assuming there are functions to covert unix time to pgtimestamptz and may be faster Looking for inverse of ts.epoch I can bypass bitwise fueld issue by assigning to int. I think Q5 can be ignored. It should work the same for execparams and execprepared. Thanks Neeraj ---1210131807-1425509699-1369241530=:69063 Content-Type: text/html; charset=us-ascii

Hi,

I forgot to mention that I'm trying to use binary data format.
I found exanples of sending string fornatted date time. However, i am assuming there are functions to covert unix time to pgtimestamptz and may be faster
Looking for inverse of ts.epoch

I can bypass bitwise fueld issue by assigning to int.
I think Q5 can be ignored. It should work the same for execparams and execprepared.

Thanks
Neeraj



From: Neeraj Rai <rneeraj@yahoo.com>;
To: pgsql-interfaces@postgresql.org <pgsql-interfaces@postgresql.org>;
Subject: [INTERFACES]
Sent: Wed, May 22, 2013 1:26:08 AM

Hi,
I'm trying a simple pgsql program with PQexecPrepared and have a few questions. 
I have seen the example but didn't find the answer there. googled too.

Q1. what format is date set in ? what is the length ?
Q2.Q2.what is the type and length of bit wise fields
Q3. how to convert seconds since epoch to date
Q4. is int passable as time?
Q5. the paramValsVec_ is char* const char[] . Can we type cast int to char* and pass in ? and set type to INT4OID?

Below is some pseudo code to put above questions in perspective.
>>. table 
CREATE TABLE t1
(curdate                 date,
str1                     varchar(19),
tm_new                  timestamptz,
count                       int);
>>> c++ code
 PGconn* pgconn; // connected
char * UpsertStmt_= "INSERT INTO t1 values( $1, $2, $3, $4)";
 int result=0;
 PGresult* pgres = PQprepare (pgconn, "stmtname", UpsertStmt_, 4, NULL);
  int result = PQresultStatus(pgres);
  PQclear(pgres_);

struct mydata
{
int curtime;
char str1[32];
int mycount;
 int mybitfield  : 3;
},
mydata myvar;
myvar.curtime = time(NULL)
strcpy(myvar.str1, hello);
myvar.mycount = 2;
myvar.mybitfield = 2;

  // set helper vars
 paramLenVec_[0]  = 8; // Q1. what format is date set in ? what is the length
 paramLenVec_[1]  = strlen(str1);
 paramLenVec_[2]  = sizeof(int);  // type = INT4OID, sizeof (int)
 paramLenVec_[3]  = sizeof(int); // Q2.what is the type and length of bit wise fields


  paramValsVec_[0]  = (char*)&myvar.curtime; // Q3. how to convert to date
  paramValsVec_[1]  = myvar.str1;
  paramValsVec_[2]  = &myvar.curtime; // Q4. is int passable as time
  paramValsVec_[3]  = (char*)&myvar.mycount; // Q5. 
PQexecPrepared (pgconn, "stmtname", 4, 
   paramValsVec_,
   paramLenVec_,
  NULL, 0
);


---1210131807-1425509699-1369241530=:69063--