From 0d3e288342a15d4876de0d0d5d5b031b5039961a Mon Sep 17 00:00:00 2001 From: janw Date: Wed, 4 Mar 2009 09:47:45 +0000 Subject: [PATCH] Use auto-increment from sqlite, no subselect anymore. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13490 594d385d-05f5-0310-b6e9-bd551577e9d8 --- trunk/gosa-si/gosa-si-server | 4 ++-- trunk/gosa-si/modules/DBsqlite.pm | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/trunk/gosa-si/gosa-si-server b/trunk/gosa-si/gosa-si-server index 514e8b1bd..0b00e52bc 100755 --- a/trunk/gosa-si/gosa-si-server +++ b/trunk/gosa-si/gosa-si-server @@ -127,7 +127,7 @@ my $watch_for_new_jobs_in_progress = 0; our $incoming_db; our $incoming_tn = 'incoming'; my $incoming_file_name; -my @incoming_col_names = ("id INTEGER PRIMARY KEY auto_increment", +my @incoming_col_names = ("id INTEGER PRIMARY KEY", "timestamp VARCHAR(14) DEFAULT 'none'", "headertag VARCHAR(255) DEFAULT 'none'", "targettag VARCHAR(255) DEFAULT 'none'", @@ -140,7 +140,7 @@ my @incoming_col_names = ("id INTEGER PRIMARY KEY auto_increment", our $job_db; our $job_queue_tn = 'jobs'; my $job_queue_file_name; -my @job_queue_col_names = ("id INTEGER PRIMARY KEY auto_increment", +my @job_queue_col_names = ("id INTEGER PRIMARY KEY", "timestamp VARCHAR(14) DEFAULT 'none'", "status VARCHAR(255) DEFAULT 'none'", "result TEXT", diff --git a/trunk/gosa-si/modules/DBsqlite.pm b/trunk/gosa-si/modules/DBsqlite.pm index cba1df504..65d289615 100644 --- a/trunk/gosa-si/modules/DBsqlite.pm +++ b/trunk/gosa-si/modules/DBsqlite.pm @@ -57,15 +57,19 @@ sub create_table { my $table_name = shift; my $col_names_ref = shift; my @col_names; + my @col_names_creation; foreach my $col_name (@$col_names_ref) { + # Save full column description for creation of database + push(@col_names_creation, $col_name); my @t = split(" ", $col_name); $col_name = $t[0]; + # Save column name internally for select_dbentry push(@col_names, $col_name); } - + $col_names->{ $table_name } = $col_names_ref; - my $col_names_string = join("', '", @col_names); - my $sql_statement = "CREATE TABLE IF NOT EXISTS $table_name ( '$col_names_string' )"; + my $col_names_string = join(", ", @col_names_creation); + my $sql_statement = "CREATE TABLE IF NOT EXISTS $table_name ( $col_names_string )"; $self->lock(); eval { my $res = $self->{dbh}->do($sql_statement); @@ -159,7 +163,7 @@ sub add_dbentry { my $sql_statement; if($create_id==1) { - $sql_statement = "INSERT INTO $table ('id', ".join(", ", @col_list).") VALUES ((select coalesce(max(id), 0)+1 from $table), ".join(", ", @val_list).")"; + $sql_statement = "INSERT INTO $table (id, ".join(", ", @col_list).") VALUES (null, ".join(", ", @val_list).")"; } else { $sql_statement = "INSERT INTO $table (".join(", ", @col_list).") VALUES (".join(", ", @val_list).")"; } -- 2.30.2