[mythtv-users] Can postgresql be used with mythtv?

Matt White whitem at arts.usask.ca
Sun Aug 22 21:14:32 EDT 2004


Jason Gabriele wrote:
>>If I recall correctly, the major
>>issue the last time I looked was the autoincrement stuff.  The code
>>inserted a stub record, got the autoincrement number back, and then 
>>went
>>on to modify the record as needed.
> 
> 
> postgres supports a serial type which is just an autoincremented int4.
> not sure if thats what you are looking for. 
> 
> "CREATE TABLE test (
>    id serial UNIQUE PRIMARY KEY
> );"
> 
> it also uses sequences where you increment it by calling nextval

Yep, I know...but mysql has (had?) a little difference where it would
do the insert and return the actual value of the autoinc field that
it just inserted.  PostgreSQL returns the OID of the record that it
just inserted...

Ah...here it is:

my_ulonglong mysql_insert_id(MYSQL *mysql)
Description

Returns the value generated for an AUTO_INCREMENT column by the previous 
INSERT or UPDATE statement. Use this function after you have performed 
an INSERT statement into a table that contains an AUTO_INCREMENT field.

I was wrong - it's a separate function, but as far as I know, psql
doesn't have anything like this out of the box.

Also, just looking at some of the code, it uses a little different
INSERT syntax than I'm familiar with...here's an example from
libs/libmythtv/dbcheck.cpp:

INSERT INTO profilegroups SET name = \"Software Encoders (v4l based)\",
cardtype = 'V4L', is_default = 1;

Where the psql version would be:

INSERT INTO profilegroups (name,cardtype,is_default) VALUES
('Software Encoders','V4L',1);

I think that this is still valid in MySQL, but don't quote me on
that :-)

-- 
Matt White                          whitem at arts.usask.ca
Arts and Science Computer Labs      University of Saskatchewan



More information about the mythtv-users mailing list