On Mon, 25 May 1998, Jose' Soares Da Silva wrote:
> Hi,
> I'm playing with pgaccess 0.86, it's a very interesting tool, congratulations
> to Teo for the excellent job.
> I would report a bug on table information:
>
> pgaccess displays the wrong size for types varchar (see your phonebook
> example):
>
> table name phonebook
> owner marco
> field information:
> ---------------------------------------
> field name field type size
> ---------------------------------------
> name varchar -5 <-- (32)
> phone_nr varchar -5 <-- (16)
> city varcahr -5 <-- (32)
> company bool 1
> continent char16 16
> ---------------------------------------
The size lenght is stored in field "attlen" for types other than VARCHAR
and BPCHAR. In this case "attlen" = -1 and size lenght+4 is stored in
field "atttypmod".
Here a bug fix:
-------------------------------------------------------------------------------
2423 proc {show_table_information} {tblname} {
2423 global dbc tiw activetab indexlist
2423 set tiw(tablename) $tblname
2423 if {$tiw(tablename)==""} return;
2423 Window show .tiw
2423 .tiw.lb delete 0 end vvvvvvvvvvvvvvvvvvvvvvvvvvv
2423 .tiw.ilb delete 0 end > field atttypmod >
2423 set tiw(isunique) {} > contains lenght >
2423 set tiw(isclustered) {} > for VARCHAR and BPCHAR >
2423 set tiw(indexfields) {} vvvvvvvvv
2423 pg_select $dbc "select attnum,attname,typname,attlen, atttypmod, usename,pg_class.oid from
pg_class,pg_user,pg_attribute,pg_typewhere (pg_class.relname='$tiw(tablename)') and
(pg_class.oid=pg_attribute.attrelid)and (pg_class.relowner=pg_user.usesys
id) and (pg_attribute.atttypid=pg_type.oid) order by attnum" rec {
2423 set fsize $rec(attlen)
2423 set ftype $rec(typname)
2423 if {$fsize=="-1"} { <- if (attlen > 0) then
2423 set fsize $rec(atttypmod) <- LENGHT = attlen
2423 incr fsize -4 <- else
2423 } <- LENGHT = attypmod - 4
2423 if {$ftype=="text"} {
2423 set fsize ""
2423 }
-----------------------------------------------------------------------------
Jose'