System information
This section builds upon previous configuration sections in this chapter.
If you have not already done so, be sure to follow the steps in the sections
“Installing PostgreSQL for CentOS” on page 342 and “Installing and
Configuring ODBC” on page 346 before continuing. In the latter sec-
tion, be sure you have enabled ODBC_STORAGE in the menuselect system
under Voicemail Options.
Alternate Centralization Method
Storing voicemail in a database is one way to centralize voicemail. Another method is
to run a standalone voicemail server, as we discussed in Chapter 8.
Creating the Large Object Type for PostgreSQL
While MySQL has a BLOB (Binary Large OBject) type, we have to tell PostgreSQL how
to handle large objects. This includes creating a trigger to clean up the data when we
delete from the database a record that references a large object.
Connect to the database as the asterisk user from the console:
$ psql -h localhost -U asterisk asterisk
Password:
You must be a superuser
to execute the following code. Also, if you use
the postgres user to create the table, you will need to use the ALTER
TABLE SQL directive to change the owner to the asterisk user.
At the PostgreSQL console, run the following script to create the large object type:
CREATE FUNCTION loin (cstring) RETURNS lo AS 'oidin' LANGUAGE internal
IMMUTABLE STRICT;
CREATE FUNCTION loout (lo) RETURNS cstring AS 'oidout' LANGUAGE internal
IMMUTABLE STRICT;
CREATE FUNCTION lorecv (internal) RETURNS lo AS 'oidrecv' LANGUAGE internal
IMMUTABLE STRICT;
CREATE FUNCTION losend (lo) RETURNS bytea AS 'oidrecv' LANGUAGE internal
IMMUTABLE STRICT;
CREATE TYPE lo ( INPUT = loin, OUTPUT = loout, RECEIVE = lorecv, SEND = losend,
INTERNALLENGTH = 4, PASSEDBYVALUE );
CREATE CAST (lo AS oid) WITHOUT FUNCTION AS IMPLICIT;
CREATE CAST (oid AS lo) WITHOUT FUNCTION AS IMPLICIT;
ODBC Voicemail | 379
Downloa d f r o m W o w ! e B o o k < w w w.woweb o o k . c o m >