Hi...

	I added this to the contrib directory for the server,  but am
wondering if anyone feels that this just might be useful as a "normal"
datatype, instead of just in the contrib directory...

Marc G. Fournier                                
Systems Administrator @ hub.org 
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org 

---------- Forwarded message ----------
Date: Sun, 11 Jan 1998 21:24:40 +0100 (CET)
From: Tom I Helbekkmo <tih@Hamartun.Priv.NO>
To: The Hermit Hacker <scrappy@hub.org>
Subject: A small type extension example for the contrib directory

Hi!

I figured the accompanying code might fit well in the contrib
directory.  I don't know who to send it to, though, so I'm just
sending it to you.  :-)  From the README:

| PostgreSQL type extensions for IP and MAC addresses.
| 
| I needed to record IP and MAC level ethernet addresses in a data
| base, and I really didn't want to store them as plain strings, with
| no enforced error checking, so I put together the accompanying code
| as my first experiment with adding a data type to PostgreSQL.  I
| then thought that this might be useful to others, both directly and
| as a very simple example of how to do this sort of thing, so here
| it is, in the hope that it will be useful.

-tih
-- 
Popularity is the hallmark of mediocrity.  --Niles Crane, "Frasier"
Sun, 25 Jan 1998 03:12:09 -0400 (AST)
The Hermit Hacker <scrappy@hub.org>
A small type extension example for the contrib directory (fwd)
On Sun, 25 Jan 1998, The Hermit Hacker wrote:

> 	I added this to the contrib directory for the server,  but am
> wondering if anyone feels that this just might be useful as a "normal"
> datatype, instead of just in the contrib directory...

I, naturally, like the idea.  :-)  However, there are problems with
the code I submitted -- as I said, it's my first shot at this:

- since then, I've learned (hi, Bruce!) that commutativity is not what
I thought it was, and that LIKE is not only not commutative, it's not
even reflexive.

- the Makefile is BSD-specific, and I don't know how to avoid this.

- my LIKE operator for IP addresses fails.  I've written about this to
the questions list, and I'm more and more certain that this has to be
a bug in PostgreSQL.  (Yes, that's arrogant of me, but I can't for the
life of me see any other possibility.  If someone could look at it
(there's a sample "test.sql" that shows the problem, and I've left the
debug output in the C source), that would be great!)

- I'm using 8 bytes of storage for each type, while I probably could
get away with 5 for IP addresses and 6 for ethernet addresses.  I just
didn't know for sure what the alignment aspects and so on were, and I
had the disk space to spare, so I never experimented to find out.

With all that said, I still think that this is both a useful data type
extension and a neat, small example of how to do this.  If it is to be
used as a base for creating a new internal data type, though, it must
be looked at carefully by someone else; I am only an egg.

I'd also like to be able to index on IP addresses, but the amount of
hair needed to add this seems to be somewhat larger than what I have.
If someone wants to show me how to extend my code to allow this, I would
very much appreciate it.

I'm attaching an updated version of the sample files.  Most of the
occurrences of "commutator = ..." are gone now, and there is a note in
the README to the effect that LIKE and NOT LIKE do not work.

-tih
-- 
Popularity is the hallmark of mediocrity.  --Niles Crane, "Frasier"
Sun, 25 Jan 1998 10:20:49 +0100 (CET)
Tom I Helbekkmo <tih@Hamartun.Priv.NO>
Re: [HACKERS] A small type extension example for the contrib
	directory (fwd)
On Sun, 25 Jan 1998, The Hermit Hacker wrote:

> 	I added this to the contrib directory for the server,  but am
> wondering if anyone feels that this just might be useful as a "normal"
> datatype, instead of just in the contrib directory...

Personally, I would, as at work, I have a database that contains all of
our machines on the network. It's a real pain handling IP & MAC addresses
as strings.

The IP type would be more useful, as I'd thought that people would use it
in things like web useage logs, etc.

> | PostgreSQL type extensions for IP and MAC addresses.
> | 
> | I needed to record IP and MAC level ethernet addresses in a data
> | base, and I really didn't want to store them as plain strings, with
> | no enforced error checking, so I put together the accompanying code
> | as my first experiment with adding a data type to PostgreSQL.  I
> | then thought that this might be useful to others, both directly and
> | as a very simple example of how to do this sort of thing, so here
> | it is, in the hope that it will be useful.

-- 
Peter T Mount  petermount@earthling.net or pmount@maidast.demon.co.uk
Main Homepage: http://www.demon.co.uk/finder
Work Homepage: http://www.maidstone.gov.uk Work EMail: peter@maidstone.gov.uk


Sun, 25 Jan 1998 10:51:20 +0000 (GMT)
Peter T Mount <psqlhack@maidast.demon.co.uk>
Re: [HACKERS] A small type extension example for the contrib
	directory (fwd)
>
>Hi...
>
>	I added this to the contrib directory for the server,  but am
>wondering if anyone feels that this just might be useful as a "normal"
>datatype, instead of just in the contrib directory...
>
>Marc G. Fournier                                
>Systems Administrator @ hub.org 
>primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org 
>

	I think this would be great as a standard tyoe. Many people wn't poke
	around n the source tree looking for neat things like this, but would
	gain even greater respect for Postgres if they found it in the default
	system. Remember we know have a lot of people installing RedHat inux,
	and being presented with Postgres as the default SQL server. 

	I would like to see them impressed by the functionality. Many of these
	people will probably want to do table with network parmaters in them.

	I recomend making it a standard type.

-- 
Stan Brown     stanb@netcom.com                                    770-996-6955
Factory Automation Systems
Atlanta Ga.
-- 
Look, look, see Windows 95.  Buy, lemmings, buy!   
Pay no attention to that cliff ahead...            Henry Spencer
(c) 1998 Stan Brown.  Redistribution via the Microsoft Network is prohibited.


Sun, 25 Jan 1998 09:45:49 -0500 (EST)
"Stan Brown" <stanb@awod.com>
Re: [HACKERS] A small type extension example for the contrib
	directory (fwd)

I think it's great for the distribution!  speaking of which, I've
written some more datetime routines which I think are pretty basic.
One just returns the datetime as the number of seconds since the epoch
(why wasn't that possible?) and the other is an interface to the
strftime function call, to custom format date strings...  what should
the function names be called?  right now i've got datetime2seconds &
strfdatetime..  any other suggestions?  and where should I submit the
code?

On Sun, 25 January 1998, at 03:12:09, The Hermit Hacker wrote:

> Hi...
> 
> 	I added this to the contrib directory for the server,  but am
> wondering if anyone feels that this just might be useful as a "normal"
> datatype, instead of just in the contrib directory...
> 
> Marc G. Fournier                                
> Systems Administrator @ hub.org 
> primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org 
> 
> ---------- Forwarded message ----------
> Date: Sun, 11 Jan 1998 21:24:40 +0100 (CET)
> From: Tom I Helbekkmo <tih@Hamartun.Priv.NO>
> To: The Hermit Hacker <scrappy@hub.org>
> Subject: A small type extension example for the contrib directory
> 
> Hi!
> 
> I figured the accompanying code might fit well in the contrib
> directory.  I don't know who to send it to, though, so I'm just
> sending it to you.  :-)  From the README:
> 
> | PostgreSQL type extensions for IP and MAC addresses.
> | 
> | I needed to record IP and MAC level ethernet addresses in a data
> | base, and I really didn't want to store them as plain strings, with
> | no enforced error checking, so I put together the accompanying code
> | as my first experiment with adding a data type to PostgreSQL.  I
> | then thought that this might be useful to others, both directly and
> | as a very simple example of how to do this sort of thing, so here
> | it is, in the hope that it will be useful.
> 
> -tih
> -- 
> Popularity is the hallmark of mediocrity.  --Niles Crane, "Frasier"

Sun, 25 Jan 1998 07:21:11 -0800
Brett McCormick <brett@abraxas.scene.com>
Re: [HACKERS] A small type extension example for the contrib
	directory (fwd)
> 
> I figured the accompanying code might fit well in the contrib
> directory.  I don't know who to send it to, though, so I'm just
> sending it to you.  :-)  From the README:

/contrib looks like a good place.  We need to re-emphasise contrib,
rather than putting this in the backend.

> 
> | PostgreSQL type extensions for IP and MAC addresses.
> | 
> | I needed to record IP and MAC level ethernet addresses in a data
> | base, and I really didn't want to store them as plain strings, with
> | no enforced error checking, so I put together the accompanying code
> | as my first experiment with adding a data type to PostgreSQL.  I
> | then thought that this might be useful to others, both directly and
> | as a very simple example of how to do this sort of thing, so here
> | it is, in the hope that it will be useful.
> 
> -tih
> -- 
> Popularity is the hallmark of mediocrity.  --Niles Crane, "Frasier"
> 
> --1426065427-653378052-884550280=:24931--
> 
> 


-- 
Bruce Momjian
maillist@candle.pha.pa.us

Sun, 25 Jan 1998 10:40:21 -0500 (EST)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] A small type extension example for the contrib
	directory (fwd)


On Sun, 25 Jan 1998, Peter T Mount wrote:

> On Sun, 25 Jan 1998, The Hermit Hacker wrote:
> 
> > 	I added this to the contrib directory for the server,  but am
> > wondering if anyone feels that this just might be useful as a "normal"
> > datatype, instead of just in the contrib directory...
> 
> Personally, I would, as at work, I have a database that contains all of
> our machines on the network. It's a real pain handling IP & MAC addresses
> as strings.
> 
> The IP type would be more useful, as I'd thought that people would use it
> in things like web useage logs, etc.
> 
> > | PostgreSQL type extensions for IP and MAC addresses.
> > | 
> > | I needed to record IP and MAC level ethernet addresses in a data
> > | base, and I really didn't want to store them as plain strings, with
> > | no enforced error checking, so I put together the accompanying code
> > | as my first experiment with adding a data type to PostgreSQL.  I
> > | then thought that this might be useful to others, both directly and
> > | as a very simple example of how to do this sort of thing, so here
> > | it is, in the hope that it will be useful.
> 

Hmm...

	It would be nice to see PgSQL integrated into Scotty/Tkined :)


-James


Sun, 25 Jan 1998 12:11:18 -0500 (EST)
James Hughes <jamesh@interpath.com>
Re: [HACKERS] A small type extension example for the contrib
	directory (fwd)
Thus spake The Hermit Hacker
> 	I added this to the contrib directory for the server,  but am
> wondering if anyone feels that this just might be useful as a "normal"
> datatype, instead of just in the contrib directory...

I have always thought that this would be useful.  Perhaps we should have
a "Would be nice if we had it" list of datatypes to see if anyone would
like to implement some.  How's this for starters?

IP addresses
MAC addresses
Phone numbers (with international and area codes)

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.

Sun, 25 Jan 1998 13:53:00 -0500 (EST)
darcy@druid.net (D'Arcy J.M. Cain)
Re: [HACKERS] A small type extension example for the contrib
	directory (fwd)
>         I added this to the contrib directory for the server,  but am
> wondering if anyone feels that this just might be useful as a "normal"
> datatype, instead of just in the contrib directory...

I second Bruce's point that contrib is a useful place and should be
re-emphasized. In particular, it is a great place for new data types and
functions to be implemented, even if they might end up in the backend in a future
release. For example, contrib has code to implement 64-bit integers, and perhaps
someday we will move them to the backend. In the meantime, you can install
anything from contrib into template1 and your whole installation can then use it.

                                                       - Tom

In hindsight, this thread is a _good_ case for contrib, since some of the
features of the candidate data type (e.g. "like" pattern matching) may not have
behaved properly and needed more work.


Tue, 27 Jan 1998 15:22:27 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [HACKERS] A small type extension example for the contrib
	directory (fwd)

Except, of course, if the database was created before the
function/types were inserted into template1, correct?

On Tue, 27 January 1998, at 15:22:27, Thomas G. Lockhart wrote:

> In the meantime, you can install
> anything from contrib into template1 and your whole installation can then use it.
> 
>                                                        - Tom
> 

Tue, 27 Jan 1998 15:57:00 -0800
Brett McCormick <brett@abraxas.scene.com>
Re: [HACKERS] A small type extension example for the contrib
	directory (fwd)