Skip to content

pvh/pgemailaddr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

emailaddr type for PostgreSQL

https://twitter.com/pvh/status/667106073199775744

This is an extension for PostgreSQL that provides a type emailaddr for storing email addresses.

Installation

To build and install this module:

make
make install

or selecting a specific PostgreSQL installation:

make PG_CONFIG=/some/where/bin/pg_config
make PG_CONFIG=/some/where/bin/pg_config install

And finally inside the database:

CREATE EXTENSION emailaddr;

Using

This module provides a data type emailaddr that you can use like a normal type. For example:

CREATE TABLE accounts (
    id int PRIMARY KEY,
    name text,
    email emailaddr
);

INSERT INTO accounts VALUES (1, 'Peter Eisentraut', '[email protected]');

The accepted addresses correspond approximately to the addr-spec production in RFC 5322 (so it's of the type [email protected], but not "Some Name" <[email protected]>).

Helper functions are available for hosts and users, and can be used thus:

SELECT emailaddr_user(email) FROM accounts WHERE emailaddr_host(email) = 'eisentraut.org';

Request for feedback

Let me now what other functionality you wish to see in an email address type.

About

email address type for PostgreSQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 66.4%
  • PLSQL 31.3%
  • Makefile 2.3%