[Oledb-dev] timestamp parameters

Shachar Shemesh psql at shemesh.biz
Thu Sep 1 06:45:50 GMT 2005


Ricardo Pardini wrote:

> Hello list,
>
>    first I wanna thank for PgOleDb. I am experimenting with it and I'm
> very pleased with the results.
>    I'm currently working with the CVS codebase (HEAD), compiled and
> working with VC++ 6 and Platform SDK.
>    I have a question about timestamp handling; when I do something like

Let me thank you for a detailed, technical, question. Those are
painfully rare of late :-(

>    When I run something like this, PgOleDb triggers the assertion at
> typeinfo::StdPGWidthInvalid. Last thing on the log before the
> assertion failure is "IAccessorImpl::GetBindings". Right after
> 'ignoring' the assertion failure, I get (in the log):


>    I suppose that in the current state, PgOleDb is capable of
> converting timestamp values sent from pgsql to the variants we need on
> the application side, but not the opposite, that is, converting valid
> datetime variants to pgsql's timestamp format. I don't even know if
> that is actually possible.  Am I on the right track here? Any pointers
> would be nice.

OleDB is a binary interface driver. In order to facilitate this, all
queries sent to the backend PG database are instructed to use a binary
interface as well.

Some (who are we kidding - all) formats have different binary
representation in the way Postgres sends them out and the way OLE DB
expects to retrieve them. For those, PgOleDb uses a binary conversion
type system. You can find the table of types at PgSess.cpp (begining
from line 33). The array begining at line 56 has a list of the types
(same order as the oids at line 33), and the functions that handle the
back and forth conversions. The functions themselves are typically
defined in TypeInfo.cpp.

I believe the type you are looking for is either of oid 1114 (timestamp)
or 1184 (timestamptz). Either way, you will find them on lines 75 and 76
of said file. You will notice that while a read conversion function is
defined for both (COPY_timestamp and COPY_timestampTZ respectively), for
the output functions they both define "StdPGC_memcpy" as the copy
function and "StdPGWidthInvalid" as the width function. In other words,
the assert you received is my humble way of saying "sorry, this
conversion is not yet supported".

If you feel up to the task, feel free to implement these three functions
(one width function, and two copy functions. One can probably call the
other, as the copyin functions currently do) and send me a patch. I was
meaning to resume doing PgOleDb work in the near future (I even have one
person from this list possibly still waiting for a price quote on a job
- sorry about that :-( ). If you do not feel up to the task, well, I was
hoping to rennovate the missing parts of the type system anyways. I'm
hoping to get around to it soon.

             Shachar


More information about the Oledb-devel mailing list