Ohad Basan has uploaded a new change for review.

Change subject: backend: changing template1 encoding to utf8
......................................................................

backend: changing template1 encoding to utf8

we can't create a new database on fedora 18 because we create a utf8
database while template1 has an ASCII encoding which is not compatible.
this patch alters the encoding of template1 on a local database.
on remote db it will display an error message.

Bug-Url : https://bugzilla.redhat.com/show_bug.cgi?id=870056
Change-Id: Ib380cc82f4ef7f30b266d29cfa27707fcb5b3601
Signed-off-by: Ohad Basan <oba...@redhat.com>
---
A backend/manager/dbscripts/alter_encoding.sql
M backend/manager/dbscripts/create_db.sh
2 files changed, 13 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/36/8936/1

diff --git a/backend/manager/dbscripts/alter_encoding.sql 
b/backend/manager/dbscripts/alter_encoding.sql
new file mode 100644
index 0000000..5da953c
--- /dev/null
+++ b/backend/manager/dbscripts/alter_encoding.sql
@@ -0,0 +1,4 @@
+UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
+DROP DATABASE template1;
+CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UTF8';
+UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
diff --git a/backend/manager/dbscripts/create_db.sh 
b/backend/manager/dbscripts/create_db.sh
index 21a5f18..601c2ba 100755
--- a/backend/manager/dbscripts/create_db.sh
+++ b/backend/manager/dbscripts/create_db.sh
@@ -45,6 +45,15 @@
 printf "Creating the database: ${DATABASE}\n"
 #try to drop the database first (if exists)
 dropdb --username=${USERNAME} --host=${SERVERNAME} --port=${PORT} ${DATABASE} 
-e > /dev/null
+RET=`execute_command "select encoding from pg_database WHERE 
datname='template1';" postgres ${SERVERNAME} ${PORT}`
+    if [[ ! $RET == 6  ]]
+        if [[ ! $SERVERNAME=="localhost"]]
+            then
+                echo "The current encoding in template1 db is not set to 
UTF8.\n in order for the engine to function properly template1 encoding must be 
UTF8"
+            else
+                execute_file "alter_encoding.sql" template0 ${SERVERNAME} 
${PORT} > /dev/null
+        fi
+    fi
 createdb --username=${USERNAME} --host=${SERVERNAME} --port=${PORT} 
${DATABASE} -e -E UTF8 -T template0 > /dev/null
 if [ $? -ne 0 ]
     then


--
To view, visit http://gerrit.ovirt.org/8936
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib380cc82f4ef7f30b266d29cfa27707fcb5b3601
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Ohad Basan <oba...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to