pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedFeature request: min/max for macaddr type
2+ messages / 2 participants
[nested] [flat]
* Feature request: min/max for macaddr type
@ 2018-03-09 14:41 Herwin Weststrate <herwin@quarantainenet.nl>
0 siblings, 1 reply; 2+ messages in thread
From: Herwin Weststrate @ 2018-03-09 14:41 UTC (permalink / raw)
To: pgsql-general
My use case: I was writing some tests where I just needed some inets and
macaddrs in a database table with certain properties. I tried to use the
following queries:
INSERT INTO inet_table (inet, ..) VALUES ((SELECT max(inet) + 1 FROM
inet_table), ...);
INSERT INTO macaddr_table (macaddr, ...) VALUES ((SELECT max(macaddr) +
1 FROM macaddr_table), ...);
This works fine for the inet type, but the macaddr failed this. I tried
adding some functions for macaddr_smaller/macaddr_larger to implement
the min/max. The code for it was very trivial, but then I got completely
lost in pg_proc.h/pg_aggregate.h. I fail to find the documentation for
this files as well, is there any reference I could use to finish my work?
--
Herwin Weststrate
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Feature request: min/max for macaddr type
@ 2018-03-09 16:54 Tom Lane <tgl@sss.pgh.pa.us>
parent: Herwin Weststrate <herwin@quarantainenet.nl>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2018-03-09 16:54 UTC (permalink / raw)
To: Herwin Weststrate <herwin@quarantainenet.nl>; +Cc: pgsql-general
Herwin Weststrate <herwin@quarantainenet.nl> writes:
> ... I tried
> adding some functions for macaddr_smaller/macaddr_larger to implement
> the min/max. The code for it was very trivial, but then I got completely
> lost in pg_proc.h/pg_aggregate.h. I fail to find the documentation for
> this files as well, is there any reference I could use to finish my work?
Well, you'd need two pg_proc entries for macaddr_smaller/macaddr_larger,
and two more for the min and max aggregates, and then two pg_aggregate
entries as well. Looking at the existing entries related to some other
datatype (inet, perhaps) ought to let you move forward.
However, if you're thinking of submitting a patch ... it's too late
for any more feature submissions for v11, and I expect that by the
time v12 opens, the bootstrap data representation will have changed,
cf the discussion at
https://www.postgresql.org/message-id/flat/CAJVSVGWO48JbbwXkJz_yBFyGYW-M9YWxnPdxJBUosDC9ou_F0Q@mail....
So, while you'll still need the same six new catalog entries, what
you actually have to write is going to look completely different.
You might want to stick this project on the back burner for a month
or so, until that dust settles.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-03-09 16:54 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 14:41 Feature request: min/max for macaddr type Herwin Weststrate <herwin@quarantainenet.nl>
2018-03-09 16:54 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox