X.50x OID representation - Mailing list pgsql-general

From redhog
Subject X.50x OID representation
Date
Msg-id 1162900663.458206.82470@h48g2000cwc.googlegroups.com
Whole thread Raw
Responses Re: X.50x OID representation  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
I need to save something very similar to X.50x IOD:s, that is, paths
where the path-components are numbers. For example: 10.5.5003.24.35.

Futhermore, I need to sort these in numerical path order, so that if
two paths are compared according to the first path component that
differs, and this path component is compared numerically, so that e.g.
100 is considered greater than 1.

Is there a suitable datatype in PostgreSQL, or some other way to
achieve this? Storing the paths as strings would make path-components
of different length compare wrongly, e.g. "91" would be considered
greater than "900", since the second digit 1 is greater than the second
digit 0.

One possibility is to store the paths as strings but with the digits
within each path component reversed, so that e.g. 4711 becomes 1174.
This would work, given that the path-separator compares less than all
digits, but is rather uggly and requires a bit of nasty rewriting when
updating/inserting/reading rows.

Any ideas?

Thanks in advance,
Egil


pgsql-general by date:

Previous
From: "William Leite Araújo"
Date:
Subject: Re: FOR ... IN
Next
From: Martijn van Oosterhout
Date:
Subject: Re: X.50x OID representation