Re: typemode for variable types
От | Greg Stark |
---|---|
Тема | Re: typemode for variable types |
Дата | |
Msg-id | CAM-w4HMcShT0-mr06vzqTLNUJ76=h0mpdJBaCSEJ7sPfb0hAHg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: typemode for variable types (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
<p dir="ltr">Also keep in mind that the system doesn't always retain the typmod. So the datum should be possible to interpretwithout the typmod. Incidental effects such as length limits or precision displayed are ok but the meaning shouldn'tbe changed.<p dir="ltr">-- <br /> greg<div class="gmail_quote">On 24 Feb 2014 20:34, "Tom Lane" <<a href="mailto:tgl@sss.pgh.pa.us">tgl@sss.pgh.pa.us</a>>wrote:<br type="attribution" /><blockquote class="gmail_quote" style="margin:00 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Alvaro Herrera <<a href="mailto:alvherre@2ndquadrant.com">alvherre@2ndquadrant.com</a>>writes:<br /> > Bruce Momjian escribió:<br /> >>Well, typmods are type-specific, so there is no official way to<br /> >> calculate it. I would look at howan existing type uses typmod and copy<br /> >> that.<br /><br /> > Our system is pretty neat. See a complexexample here:<br /> > <a href="https://github.com/postgis/postgis/blob/svn-trunk/postgis/gserialized_typmod.c" target="_blank">https://github.com/postgis/postgis/blob/svn-trunk/postgis/gserialized_typmod.c</a><br/><br /> One other pointis that if you do consult the varchar functions as<br /> an example, be aware that there's an offset of 4 in their definition<br/> of the typmod (eg, for varchar(3) the stored typmod is 7). This is<br /> entirely for legacy reasons sothere's no good reason to duplicate it<br /> in a new custom-made type. Except for the rule that negative values<br />mean "unspecified typmod" (which you have to support), you can<br /> define the contents of the typmod value however youwant.<br /><br /> regards, tom lane<br /><br /><br /> --<br /> Sent via pgsql-hackers mailinglist (<a href="mailto:pgsql-hackers@postgresql.org">pgsql-hackers@postgresql.org</a>)<br /> To make changes to yoursubscription:<br /><a href="http://www.postgresql.org/mailpref/pgsql-hackers" target="_blank">http://www.postgresql.org/mailpref/pgsql-hackers</a><br/></blockquote></div>
В списке pgsql-hackers по дате отправления: