Ads were blocked by your webbrowser.

This is not a problem, but keep in mind that developing HeidiSQL, user support and hosting takes time and money.

You may want to send a donation instead.

PostgreSQL Table Column Order Bug

jnp's profile image jnp posted 5 years ago in General
A recent build of HeidiSQL seems to have introduced a bug that results in the columns in tables being displayed out-of-order. This occurs in both the column list and the data browser. The most significant problem with this is that the column in the data browser have incorrect headings for the data contained in them.

I believe that the source of this problem is this query:
SELECT DISTINCT
a.attnum,
a.attname AS column_name,
FORMAT_TYPE(a.atttypid, a.atttypmod) AS data_type,
CASE a.attnotnull WHEN FALSE THEN 'YES' ELSE 'NO' END AS IS_NULLABLE,
com.description AS column_comment,
def.adsrc AS column_default,
NULL AS character_maximum_length
FROM pg_attribute AS a
JOIN pg_class AS pgc ON pgc.oid = a.attrelid
LEFT JOIN pg_description AS com ON (pgc.oid = com.objoid AND a.attnum = com.objsubid)
LEFT JOIN pg_attrdef AS def ON (a.attrelid = def.adrelid AND a.attnum = def.adnum)
WHERE a.attnum > 0
AND pgc.oid = a.attrelid
AND pg_table_is_visible(pgc.oid)
AND NOT a.attisdropped
AND pgc.relname = 'my_table';


I suspect this issue can be resolved by simply adding this line to the end of the query:
ORDER BY a.attnum;


Thanks.
ansgar's profile image ansgar posted 5 years ago
Fixed in r4855

Please login to leave a reply, or register at first.