[PostgreSQL] Support for uuid type

arturm's profile image arturm posted 9 years ago in Feature discussion Permalink
UUID type is not supported for PG connections.
Unknown datatype "UUID" for "entity". Fall back to UNKNOWN.
ansgar's profile image ansgar posted 9 years ago Permalink
Would it be sufficient to display and edit uuid values like ordinary text values?
arturm's profile image arturm posted 9 years ago Permalink
It will be OK. Thank you.
Code modification/commit from ansgarbecker, 9 years ago, revision 9.2.0.4951
Add support for PostgreSQL's UUID data type. See http://www.heidisql.com/forum.php?t=18442
ansgar's profile image ansgar posted 9 years ago Permalink
Added support for UUID data type in r4951.
arturm's profile image arturm posted 9 years ago Permalink
I am not sure about the solution. Query log on click "Data" tab is the following (sorry for polish locale):

/* Ładowanie sesji "PostgreSQL lokalny" */
SELECT "entity", SUBSTR("class", 1, 256), "minver", "maxver", SUBSTR("name", 1, 256) FROM "public"."entities" LIMIT 1000;
/* BŁĄD: funkcja substr(uuid, integer, integer) nie istnieje
LINE 1: SELECT "entity", SUBSTR("class", 1, 256), "minver", "max...
^
HINT: Brak funkcji pasującej do podanej nazwy i typów argumentów. Być może należy dodać jawne rzutowanie typów. */

Translation: function substr(uuid, integer, integer) doesn't exist
Columns entity and class are UUIDs, name is varchar. What is SUBSTR used for? Anyway it doesn't work.

arturm's profile image arturm posted 9 years ago Permalink
If casting to string is really required, maybe you should try CAST("entity" as character varying) or old styled "entity"::character varying
[expired user #8358]'s profile image [expired user #8358] posted 9 years ago Permalink
Yep, I'm getting the same error when trying to view the "Data" tab of a table with UUID columns:

function substr(uuid, integer, integer) does not exist...

It works okay when the first column is a UUID type (no attempt to use substr()), but in this table I have a second column that is also a UUID type (and a foreign key).

Example table create code:

CREATE TABLE "items" (
"item_id" UUID NOT NULL,
"merchant_id" UUID NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT NOT NULL,
PRIMARY KEY ("item_id")
);
Code modification/commit from ansgarbecker, 9 years ago, revision 9.2.0.4952
Introduce new data type property "LoadPart" (boolean), which says whether such columns can be loaded per SUBSTR or LEFT into the data grid. Set it to false for UUID and JSON. See http://www.heidisql.com/forum.php?t=18442
ansgar's profile image ansgar posted 9 years ago Permalink
Fixed in r4952
[expired user #8358]'s profile image [expired user #8358] posted 9 years ago Permalink
Confirmed it works for tables with multiple UUID columns. Thank you!

However, I found it giving a similar error with the 'inet' type: it shows in the Table tab as a 'VARCHAR' (technically incorrect), renders fine in the query tab if I do a SELECT * with an inet type, but fails with the SUBSTR() error message in the Data tab. (I imagine the other netwrok address types will do the same.)
Code modification/commit from ansgarbecker, 9 years ago, revision 9.2.0.4953
Support PostgreSQL data types cidr, inet and macaddr. Grouped in dtcText category, so the grids show the normal text editor, but without applying SUBSTR(). See http://www.heidisql.com/forum.php?t=18442
ansgar's profile image ansgar posted 9 years ago Permalink
cidr, inet and macaddr types added in r4953. These were formerly detected as varchar. Now, the grids still offer the normal text editor for these types, but without applying the SUBSTR() logic, so it does not crash when you have such columns.
arturm's profile image arturm posted 9 years ago Permalink
Thank you for your support! Now HeidiSQL is usable for viewing queries. Still some work on table editing part (foreign keys, sequences etc) then it is cool replacement for PgAdminIII.
[expired user #8358]'s profile image [expired user #8358] posted 9 years ago Permalink
Confirmed that r4953 fixes the network address types display. Thank you again for a quick fix!
ansgar's profile image ansgar posted 9 years ago Permalink
Thank *you* for consistent and helpful feedback!

So I shall have a look at foreign keys for PostgreSQL. I just found a query at StackOverflow:
SELECT
tc.constraint_name, tc.table_name, kcu.column_name, 
ccu.table_name AS foreign_table_name,
ccu.column_name AS foreign_column_name 
FROM 
information_schema.table_constraints AS tc 
JOIN information_schema.key_column_usage AS kcu
ON tc.constraint_name = kcu.constraint_name
JOIN information_schema.constraint_column_usage AS ccu
ON ccu.constraint_name = tc.constraint_name
WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name='mytable';

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