rip out postgres support
authorIan Beckwith <ianb@erislabs.net>
Mon, 18 Oct 2010 02:34:37 +0000 (03:34 +0100)
committerIan Beckwith <ianb@erislabs.net>
Mon, 18 Oct 2010 02:34:37 +0000 (03:34 +0100)
lib/ID3FS/DB.pm
lib/ID3FS/Path.pm

index 955e117..deaa16e 100644 (file)
@@ -28,15 +28,8 @@ sub new
     $self->{absbase}=Cwd::abs_path($self->{base});
 
     my $connectstr="dbi:SQLite:dbname=$self->{dbpath}";
-    my ($user, $pass)=("", "");
-    if($self->{postgres})
-    {
-       $connectstr="dbi:Pg:dbname=id3fs";
-       $user="ianb";
-       $pass="foo";
-    }
     my $exists=-f $self->{dbpath};
-    $self->{dbh}=DBI->connect($connectstr, $user, $pass,
+    $self->{dbh}=DBI->connect($connectstr, undef, undef,
                              { AutoCommit=>1 } );
     unless(defined($self->{dbh}))
     {
@@ -110,23 +103,6 @@ sub create
     {
        $self->{dbh}->do($cmd);
     }
-    if($self->{postgres})
-    {
-       $self->cmd("CREATE SEQUENCE seq");
-    }
-    else
-    {
-       my %indexes=( "idx_files_id"  => "files (id)",
-                     "idx_fxt_both"  => "files_x_tags (files_id, tags_id)",
-                     "idx_fxt_files" => "files_x_tags (files_id)",
-                     "idx_fxt_tags"  => "files_x_tags (tags_id)",
-                     "idx_tags_id"   => "tags (id)",
-                     "idx_tags_name" => "tags (name)");
-       for my $index (keys %indexes)
-       {
-           $self->{dbh}->do("CREATE INDEX $index ON " . $indexes{$index});
-       }
-    }
     $self->cmd("INSERT INTO id3fs (schema_version, last_update) VALUES (?, ?)",
               $SCHEMA_VERSION, time());
 }
@@ -336,7 +312,6 @@ sub add_to_table
     unless(defined($id))
     {
        my $sql="INSERT INTO $table (";
-       $sql .= "id, " if($self->{postgres});
        my @fields=qw(name);
        if(defined($extradata))
        {
@@ -344,7 +319,6 @@ sub add_to_table
        }
        $sql .= join(", ", @fields);
        $sql .=") VALUES (";
-       $sql .=") nextval('seq'), " if($self->{postgres});
        $sql .= join(", ", map { "?"; } @fields);
        $sql .= ");";
        $id=$self->cmd_id($sql, $name, map { $extradata->{$_} || ""; } sort keys %$extradata);
@@ -523,15 +497,7 @@ sub cmd_id
 sub last_insert_id
 {
     my $self=shift;
-    if($self->{postgres})
-    {
-       return $self->{dbh}->last_insert_id(undef, undef, undef, undef,
-                                           { sequence => "seq" });
-    }
-    else
-    {
-       return $self->{dbh}->last_insert_id("","","","");
-    }
+    return $self->{dbh}->last_insert_id("","","","");
 }
 
 sub lookup_id
@@ -599,3 +565,15 @@ CREATE TABLE files_x_tags (
     FOREIGN KEY(tags_id)  REFERENCES tags(id)  ON DELETE CASCADE ON UPDATE CASCADE
 );
 
+CREATE INDEX idx_files_id ON files (id)
+
+CREATE INDEX idx_fxt_both ON files_x_tags (files_id, tags_id)
+
+CREATE INDEX idx_fxt_files ON files_x_tags (files_id)
+
+CREATE INDEX idx_fxt_tags ON files_x_tags (tags_id)
+
+CREATE INDEX idx_tags_id ON tags (id)
+
+CREATE INDEX idx_tags_name ON tags (name)
+
index cc0c041..b3be955 100644 (file)
@@ -836,12 +836,9 @@ sub constraints_tag_list
            }
        }
     }
-    unless($self->{db}->{postgres})
-    {
-       @tags=map{ "\"$_\""; } @tags;
-       @tags_vals=map( { [ map({ "\"$_\""; } @$_ ) ] } @tags_vals);
-       $lasttag="\"$lasttag\"" if defined($lasttag);
-    }
+    @tags=map{ "\"$_\""; } @tags;
+    @tags_vals=map( { [ map({ "\"$_\""; } @$_ ) ] } @tags_vals);
+    $lasttag="\"$lasttag\"" if defined($lasttag);
     return(\@tags, \@tags_vals, $lasttag);
 }