1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
diff --git a/debian/scripts/help_database_update_scripts_extractor_v13.patch b/debian/scripts/help_database_update_scripts_extractor_v13.patch
index 3ae5287c..e69de29b 100644
--- a/debian/scripts/help_database_update_scripts_extractor_v13.patch
+++ b/debian/scripts/help_database_update_scripts_extractor_v13.patch
@@ -1,39 +0,0 @@
-diff --git a/src/cats/update_mysql_tables.in b/src/cats/update_mysql_tables.in
-index f4b3f9e4..a66f043d 100644
---- a/src/cats/update_mysql_tables.in
-+++ b/src/cats/update_mysql_tables.in
-@@ -30,8 +30,9 @@ ARGS=$*
-
- getVersion()
- {
-- mysql $ARGS -D ${db_name} -e "select VersionId from Version LIMIT 1\G" >/tmp/$$
-- DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$`
-+ if test -f $OUTFILE; then
-+ DBVERSION=`grep "UPDATE Version SET VersionId" $OUTFILE | tail -n 1 | sed 's/^[^0-9]*\([0-9][0-9]*\)[^0-9]*;/\1/'`
-+ fi
- }
-
- getVersion
-diff --git a/src/cats/update_sqlite3_tables.in b/src/cats/update_sqlite3_tables.in
-index 2a5efd72..f4a337c5 100644
---- a/src/cats/update_sqlite3_tables.in
-+++ b/src/cats/update_sqlite3_tables.in
-@@ -13,13 +13,13 @@ echo " "
-
- bindir=@SQLITE_BINDIR@
- PATH="$bindir:$PATH"
--cd @working_dir@
-+#cd @working_dir@
- db_name=@db_name@
-
--DBVERSION=`sqlite3 ${db_name}.db <<END
--SELECT VersionId FROM Version LIMIT 1;
--END
--`
-+#DBVERSION=`sqlite3 ${db_name}.db <<END
-+#SELECT VersionId FROM Version LIMIT 1;
-+#END
-+#`
- if [ "$DBVERSION" -ne $OLDVERSION ] ; then
- if [ "$DBVERSION" -lt 12 -o "$DBVERSION" -gt $NEWVERSION ] ; then
- echo " "
diff --git a/src/cats/update_mysql_tables.in b/src/cats/update_mysql_tables.in
index d4bb96da..2c249b4f 100644
--- a/src/cats/update_mysql_tables.in
+++ b/src/cats/update_mysql_tables.in
@@ -32,8 +32,9 @@ ARGS=$*
getVersion()
{
- mysql $ARGS -D ${db_name} -e "select VersionId from Version LIMIT 1\G" >/tmp/$$
- DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$`
+ if test -f $OUTFILE; then
+ DBVERSION=`grep "UPDATE Version SET VersionId" $OUTFILE | tail -n 1 | sed 's/^[^0-9]*\([0-9][0-9]*\)[^0-9]*;/\1/'`
+ fi
}
getVersion
diff --git a/src/cats/update_postgresql_tables.in b/src/cats/update_postgresql_tables.in
index 9b808305..70d8548b 100644
--- a/src/cats/update_postgresql_tables.in
+++ b/src/cats/update_postgresql_tables.in
@@ -34,7 +34,9 @@ ARGS=$*
getVersion()
{
- DBVERSION=`psql -d ${db_name} -t --pset format=unaligned -c "select VersionId from Version LIMIT 1" $ARGS`
+ if test -f $OUTFILE; then
+ DBVERSION=`grep -i "UPDATE Version SET VersionId" $OUTFILE | tail -n 1 | sed 's/^[^0-9]*\([0-9][0-9]*\)[^0-9]*;/\1/'`
+ fi
}
getVersion
@@ -161,100 +163,7 @@ if [ "$DBVERSION" -eq 15 -o "$DBVERSION" -eq 16 ]; then
if [ "$DBVERSION" -eq 16 ]; then
SKIP1018=1
fi
-
- # Can be adjusted
- WORKMEM=1GB
-
- COMP=`which pigz`
- if [ "$COMP" = "" ]; then
- COMP=`which pbzip2`
- if [ "$COMP" = "" ]; then
- COMP=`which lzop`
- if [ "$COMP" = "" ]; then
- COMP=`which gzip`
- if [ "$COMP" = "" ]; then
- echo "Error. Cannot find pigz, pbzip2, lzop or gzip"
- exit 1
- fi
- fi
- fi
- fi
-
- echo "Dumping File table to $PWD/file1017.data. "
- echo ""
- echo "The process may fail if the current user"
- echo " doesn't have write permission on the current directory,"
- echo " or if the system doesn't have enough space to store a"
- echo " compressed export of the File table"
- psql --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, MarkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1017.data
-
- if [ $? -ne 0 ]; then
- echo "Error while dumping file table to $PWD/file1017.data"
- exit 1
- fi
-
- if ! psql --set ON_ERROR_STOP=1 -f - -d ${db_name} $* <<EOF
-BEGIN;
-
-DROP TABLE File;
-DROP TABLE Filename;
-
-CREATE TABLE File
-(
- FileId bigint not null,
- FileIndex integer not null default 0,
- JobId integer not null,
- PathId integer not null,
- Filename text not null default '',
- DeltaSeq smallint not null default 0,
- MarkId integer not null default 0,
- LStat text not null,
- Md5 text not null
-);
-
-COMMIT;
-EOF
- then
- echo "Creation of new File table failed."
- exit 1
- fi
-
- echo "Loading the File table from $PWD/file.$$.data..."
- # we do everything in the same commit to avoid creating WALs on this operation
- cat file1017.data | $COMP -d | psql --set ON_ERROR_STOP=1 -d ${db_name} $* -c "BEGIN; TRUNCATE File; COPY File FROM STDIN; set maintenance_work_mem='2000MB'; CREATE INDEX file_jpfid_idx on File (JobId, PathId, Filename text_pattern_ops); ALTER TABLE ONLY File ADD CONSTRAINT file_pkey PRIMARY KEY (FileId); COMMIT;"
-
- if [ $? -ne 0 ]; then
- echo "Inserting File data from file.$$.data failed."
- exit 1
- fi
-
- echo "Creation of indexes and PK on the File table..."
-
- # The maximum value for maintenance_work_mem is 2GB
- if ! psql --set ON_ERROR_STOP=1 -f - -d ${db_name} $* <<EOF
-set maintenance_work_mem='2000MB';
-BEGIN;
-CREATE SEQUENCE file_fileid_seq;
-ALTER SEQUENCE file_fileid_seq OWNED BY File.fileid;
-SELECT pg_catalog.setval('file_fileid_seq', (SELECT MAX(FileId) FROM File), true);
-ALTER TABLE File ALTER COLUMN FileId SET DEFAULT nextval('file_fileid_seq'::regclass);
-
-ANALYZE File;
-
-ALTER TABLE Media ALTER VolWrites TYPE BIGINT;
-ALTER TABLE unsavedfiles DROP COLUMN filenameid;
-ALTER TABLE unsavedfiles ADD COLUMN filename text not null;
-
-UPDATE Version SET VersionId = 1017;
-
-COMMIT;
-EOF
- then
- echo "Index creation for Bacula PostgreSQL tables."
- exit 1
- fi
echo "Upgrade of the File table succeeded. Version 1017"
- rm -f file1017.data
getVersion
fi
diff --git a/src/cats/update_sqlite3_tables.in b/src/cats/update_sqlite3_tables.in
index 4aaa5be1..7db63623 100644
--- a/src/cats/update_sqlite3_tables.in
+++ b/src/cats/update_sqlite3_tables.in
@@ -15,13 +15,13 @@ echo " "
bindir=@SQLITE_BINDIR@
PATH="$bindir:$PATH"
-cd @working_dir@
+#cd @working_dir@
db_name=@db_name@
-DBVERSION=`sqlite3 ${db_name}.db <<END
-SELECT VersionId FROM Version LIMIT 1;
-END
-`
+#DBVERSION=`sqlite3 ${db_name}.db <<END
+#SELECT VersionId FROM Version LIMIT 1;
+#END
+#`
if [ "$DBVERSION" -ne $OLDVERSION ] ; then
if [ "$DBVERSION" -lt 12 -o "$DBVERSION" -gt $NEWVERSION ] ; then
echo " "
|