User-defined type send/recv vs. out/in

User-defined type send/recv vs. out/in

Post by Don » Tue, 14 Feb 2012 14:31:05



Hi,

While in() and out() routines are required for a type,
recv() and send() are "optional".

Could someone clarify when recv/send are used in preference
to in/out?  Any way to force the use of one set or the
other (assuming all are defined)?

And, while I'm at it, any pointers to a comprehensive
summary of these issues?  (I've been poking through
the source distribution...)

Thx,
--don

 
 
 

User-defined type send/recv vs. out/in

Post by Jasen Bett » Tue, 14 Feb 2012 18:33:49



Quote:> Hi,

> While in() and out() routines are required for a type,
> recv() and send() are "optional".

I can't find that twxt anywhere.

Quote:> Could someone clarify when recv/send are used in preference
> to in/out?  Any way to force the use of one set or the
> other (assuming all are defined)?

I'm guessing in/out is for disk storage and send/recv
for the line protocol.

Quote:> And, while I'm at it, any pointers to a comprehensive
> summary of these issues?  (I've been poking through
> the source distribution...)

I didn't look at that, that's probably whay I didn't find it.

there's a mailing list "postgresql.hackers" where the people who
work on the deep internals hang out. you can reach it thuough
gmane if you prefer an NNTP interface, but you need to sign up at
http://www.postgresql.org/community/lists/ to post.

--
?? 100% natural



 
 
 

User-defined type send/recv vs. out/in

Post by Don » Wed, 15 Feb 2012 06:06:56


Hi Jasen,



>> While in() and out() routines are required for a type,
>> recv() and send() are "optional".

> I can't find that twxt anywhere.

Part of the standard manual:

<http://www.postgresql.org/docs/7.4/static/xtypes.html>

(Sorry I posted the URL for v7.4... the text is largely
the same for subsequent versions).

Note, specifically, the casual mention of the send and recv
functions...

Quote:>> Could someone clarify when recv/send are used in preference
>> to in/out?  Any way to force the use of one set or the
>> other (assuming all are defined)?

> I'm guessing in/out is for disk storage and send/recv
> for the line protocol.

in and out talk "people-speak".  I.e., they provide a way
to convey the contents of the typed variable to the human
user.  I.e., it imposes the syntax that the type wants
(as defined by the type implementor) and provides a mapping
to/from the internal representation.

send and recv are for "binary I/O".  The first thing that comes
to mind is a *dump*.  But, dumps generate actual SQL so...
(obviously, there is a way that send/recv can be used.  The
question is:  what drives/invokes that and what are the
consequences if it is not implemented?)

Quote:>> And, while I'm at it, any pointers to a comprehensive
>> summary of these issues?  (I've been poking through
>> the source distribution...)

> I didn't look at that, that's probably whay I didn't find it.

There's a tutorial there (that mimics the one on the manual page)

Quote:> there's a mailing list "postgresql.hackers" where the people who
> work on the deep internals hang out. you can reach it thuough
> gmane if you prefer an NNTP interface, but you need to sign up at
> http://www.postgresql.org/community/lists/ to post.

Yes, I've been trying to avoid pestering those folks on the
assumption that they have better things to do than attend to my
"simple" questions  :-/  I figured the user types are exposed
in the manual (whereas much of the internals are NOT) so hoping
other "users" would have first-hand experience.
 
 
 

User-defined type send/recv vs. out/in

Post by Don » Thu, 16 Feb 2012 14:57:24


Hi Jasen,



>> send and recv are for "binary I/O".  The first thing that comes
>> to mind is a *dump*.  But, dumps generate actual SQL so...
>> (obviously, there is a way that send/recv can be used.  The
>> question is:  what drives/invokes that and what are the
>> consequences if it is not implemented?)

> obvously the text form is need for server features like COPY ... TO
> and COPY ... FROM , (and the binary form when using the WITH BINARY
> clause on COPY) but this is not the whole picture...

> this page discusses binary format when using libpq
> http://www.postgresql.org/docs/9.1/static/libpq-exec.html

> It seems if you use a special query function like PQexecparams
> you can ask for the results in binary else if you use
> ordinary PQexec you're only going to get them in text.

Yes.  Notably absent (implied?) are the consequences of specifying
a "binary" pgFormats[] indicator for a paramType[] that doesn't
have _send/_recv() support.  (I suppose the interface could
silently replace a "text" format on each end of the API and
just incur the performance hit.  Of course, it could also
*complain*!  :> )

- Show quoted text -

Quote:> if you're not using libpq (eg using java or odbc) yuo'll probably only
> be able to use the text form.

>>> there's a mailing list "postgresql.hackers" where the people who
>>> work on the deep internals hang out. you can reach it thuough
>>> gmane if you prefer an NNTP interface, but you need to sign up at
>>> http://www.postgresql.org/community/lists/ to post.

>> Yes, I've been trying to avoid pestering those folks on the
>> assumption that they have better things to do than attend to my
>> "simple" questions  :-/  I figured the user types are exposed
>> in the manual (whereas much of the internals are NOT) so hoping
>> other "users" would have first-hand experience.

> The developers (especially Tom Lane) seem to be happy to help out
> people with tricky questions in the general mailing list.
> that's a high volume list (~100/day).  people with easy questions are
> usually helped by the other list members.

I think I've found a work-around that truly makes send/recv
"optional" in my case.  My original query was motivated by
fear over what *might* want to rely on that instead of in/out
but I think I've eliminated that concern (coupled with your
pointers, above)

Thanks!
--don

 
 
 

1. CREATE TYPE containing array of user-defined type elements

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there!

We're trying to create a user-defined type in PostgreSQL 8.2 containing an
array of an element whose type is another user-defined one. We're facing a
problem here, since when we try to do so:

CREATE TYPE newtype AS(
 x double precision,
 y double precision
);

CREATE TYPE newtype2(
 INPUT=array_in,
 OUTPUT=array_out,
 ELEMENT=newtype
);

PostgreSQL complains about non-existent array_out(newtype2). So, we felt
into this forum
http://osdir.com/ml/db.postgresql.novice/2003-07/msg00147.html and someone
suggested creating an alias to array_out because postgresql >= 7.3 is too
much strict about data types ot whatever.

Since we can't access as admin, we can't solve the problem like that. We
can't create an alias for array_out if we're not admins.

Please, we need some help. Thank you.

- --

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iQIVAwUBRxH8x6vCV+KC5A6ZAQJpKxAAgpeHCeDfy/jZ421zs/3tDhNBeQavF2h9
aLRdHV9kiXuB4+NL73tAiTPzqXs042MdDQxKmq3Bg2/WMkgwR2f04hEdWGN8a6hj
JtUKJY29i5BU2gfnfoep/yN6oyTN0qj6Vn2VRryx2cyAX4iA3KxIPpeJpTE9xMsX
S7KFuG+3AC4zSaFqlVt5bczbzm+wrWH4UPLho6FMsZTSo7TLruCWbApL4qRWlSrL
AgG6KFKuT1zNN82SVt6v29KTB80/YBfbHKoUqWn1dJPl/aqVDYH4HKZxR6fZyt2F
WRxPnXjtAAVzPkEJQyqtJpxLQlJ/t0XfGPJ0NZzHXrSnLSp0ms2MxsXn66qLAzXW
yYPF2fadDkh+0RB+mb2Sp6n7cCvRQjx0df56gQysQscYoEtV8drRGHzmoOwsIJaV
fTSmfrpwkkIlPHB314ERfXFJ6jno50vJBv3syP4jYvNlKonsM5PCp/UpvEZgBBh6
jhFzoNsP6zbqv5/GKYiBuo5TsfQWSo38K3l6rLtynvaNhpQ8PBnWwiityciSB2G9
N77NghXU87MbHSD6pCOgCbt5ykncaKtPRPuPp3EcQuvVal75M4ND7DRyNDQ6v74H
shpva7fz0w37Bgh65D+MofeaCK3kEwkReYQ4sdN/X400yCQcl97G41rbcMf/tj0u
LUzf5GRmxfw=
=mKq/
-----END PGP SIGNATURE-----

2. win 98 and win 2000 together

3. User-defined type -- error handling

4. Driveway sensors

5. ECPG and User-defined Types.

6. Alignment of controls

7. Schema + User-Defined Data Type Indexing problems...

8. textures

9. User defined data types

10. ENUMs as user defined types?

11. user defined data types

12. Workaround or user defined type

13. How save user defined type in SQL2000 DataBase???