Thread: pg_attributte, data types

pg_attributte, data types

From
Viktor Bojović
Date:
while listing data types i have noticed that some types have underscore prefix but i don't know why is that. so im asking if somene can tell me.
These are type examples:

_char
_float4
_int2
_oid
_regtype
_text
_varchar


select distinct typname
from
(
SELECT attname AS name,
attnum ,
typname,
atttypmod - 4 as length,
attnotnull AS notnull,
atthasdef AS def,
c.oid AS tbloid,
d.adsrc AS defval,
ds.description,
attndims AS dimnum,
attstattarget,
attislocal,
attinhcount

FROM pg_attribute a
INNER JOIN pg_class c ON a.attrelid = c.oid
INNER JOIN pg_type t ON a.atttypid = t.oid
LEFT OUTER JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = a.attnum
LEFT OUTER JOIN pg_description ds ON ds.objoid = c.oid AND ds.objsubid =
a.attnum
INNER JOIN pg_namespace n ON t.typnamespace = n.oid
WHERE attnum > 0 AND
attisdropped <> 't'
ORDER BY a.attnum
) as foo


--
---------------------------------------
Viktor Bojović
---------------------------------------
Wherever I go, Murphy goes with me

Re: pg_attributte, data types

From
Tom Lane
Date:
Viktor Bojović <viktor.bojovic@gmail.com> writes:
> while listing data types i have noticed that some types have underscore
> prefix but i don't know why is that. so im asking if somene can tell me.
> These are type examples:

> _char
> _float4
> _int2
> _oid
> _regtype
> _text
> _varchar

Those are array types.  The normal convention is that foo[] is named
"_foo" under the surface.
        regards, tom lane


Re: pg_attributte, data types

From
Viktor Bojović
Date:
<br /><br /><div class="gmail_quote">On Thu, Mar 24, 2011 at 12:56 AM, Tom Lane <span dir="ltr"><<a
href="mailto:tgl@sss.pgh.pa.us">tgl@sss.pgh.pa.us</a>></span>wrote:<br /><blockquote class="gmail_quote"
style="margin:0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">Viktor
Bojović<<a href="mailto:viktor.bojovic@gmail.com">viktor.bojovic@gmail.com</a>> writes:<br /> > while listing
datatypes i have noticed that some types have underscore<br /> > prefix but i don't know why is that. so im asking
ifsomene can tell me.<br /> > These are type examples:<br /><br /> > _char<br /> > _float4<br /> > _int2<br
/>> _oid<br /> > _regtype<br /> > _text<br /> > _varchar<br /><br /></div>Those are array types.  The
normalconvention is that foo[] is named<br /> "_foo" under the surface.<br /><br />                        regards, tom
lane<br/></blockquote></div><br />thanx<br clear="all" /><br />-- <br />---------------------------------------<br
/>ViktorBojović<br />---------------------------------------<br />Wherever I go, Murphy goes with me<br />