Converting timestamps and IP addresses

From: Erwin Van de Velde <erwin(dot)vandevelde(at)ua(dot)ac(dot)be>
To: pgsql-general(at)postgresql(dot)org
Subject: Converting timestamps and IP addresses
Date: 2004-02-11 11:12:17
Message-ID: 200402111212.17031.erwin.vandevelde@ua.ac.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm building a central logging system for security applications as my master
thesis, but I've run into some troubles:

Different applications make database logs using different formats:
- Timestamps as timestamps or as numeric values
- IP addresses in dotted notation (aaa.bbb.ccc.ddd) or as numeric values

I'd like to convert these to the same type, so that I can compare them. Two
questions thereby:
- Is there an easy way with built-in functions? (I didn't found them)
- Can I use triggers and C-functions to reach my goal?

For the second question: in that case, all tables in my database would have
the same dataformat for timestamps and IP's, and conversion would happen at
insertion. However, there could be a data type mismatch between what stays in
the query (a numeric value for instance) and the column type in the database
(string type: dotted notation for IP): So, when are the types checked? Before
or after a trigger on INSERT? (Of course when using a TRIGGER BEFORE INSERT
:-)) I'm only wondering when type checks are executed...

If anyone has built such functions already, I'd gladly accept, and you can win
a line in my thank word ;-)

Greetings,
Erwin Van de Velde
Student of University of Antwerp,
Belgium

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2004-02-11 11:30:31 Re: DB cache size strategies
Previous Message Richard Huxton 2004-02-11 10:59:18 Re: DB cache size strategies