Commit b6f9c0e2 authored by Giuseppe Lo Presti's avatar Giuseppe Lo Presti
Browse files

Don't append trailer.sql part to the generated SQL creation script

parent 9b8b543b
......@@ -5,7 +5,7 @@
#
# @author Castor dev team, castor-dev@cern.ch
#
# @(#)$RCSfile: gencastor,v $ $Revision: 1.16 $ $Release$ $Date: 2007/04/30 12:47:38 $ $Author: itglp $
# @(#)$RCSfile: gencastor,v $ $Revision: 1.17 $ $Release$ $Date: 2007/07/02 14:32:25 $ $Author: itglp $
#
if ("$1" == "-h") then
......@@ -40,19 +40,18 @@ rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}/${TOPNS}/db
cp ${WORKDIR}/${TOPNS}/db/*.sql ${TMPDIR}/${TOPNS}/db/
grep 'CREATE OR REPLACE' ${TMPDIR}/${TOPNS}/db/postgresTrailer.sql | grep -v 'TRIGGER' | grep -v I_CastorFile_fileIdNsHost | awk 'BEGIN { FS="[ (]+" } { print "DROP " $4, $5 ";" }' > ${TMPDIR}/${TOPNS}/db/postgresTrailer_drop.sql
# removes CVS keywords
sed 's/\$//g' ${TMPDIR}/${TOPNS}/db/oracleTrailer.sql > ${TMPDIR}/ora.sql
mv ${TMPDIR}/ora.sql ${TMPDIR}/${TOPNS}/db/oracleTrailer.sql
(/usr/bin/gencastor.bin -o ${TMPDIR} -c ${TOPNS} --nocrashhandler ${XMIFILE} > /dev/tty) >& /dev/null
sed 's/^END;/END;\n\//' ${TMPDIR}/${TOPNS}/db/${TOPNS}_oracle_create.sql | sed 's/^\(END castor[a-zA-Z]*;\)/\1\n\//' | sed 's/\(CREATE OR REPLACE TYPE .*\)$/\1\n\//' > ${TMPDIR}/${TOPNS}/db/${TOPNS}_oracle_create.sqlplus
if ($? > 0) then
echo Error during code generation, exiting
exit
endif
set pushdsilent
pushd ${TMPDIR}
rm -f ${TOPNS}/db/*Generated*
rm -f ${TOPNS}/db/*Trailer_drop*
rm -f ${TOPNS}/db/oracleTrailer.sql
rm -f ${TOPNS}/db/*Trailer*
foreach f (`find . -type f`)
#echo $f
......
......@@ -37,7 +37,7 @@ CppCppDbCnvWriter::~CppCppDbCnvWriter() {
void CppCppDbCnvWriter::startSQLFile() {
// Preparing SQL files for creation/deletion of the database(s)
QFile file;
openFile(file, s_topNS + "/db/" + s_topNS + "_oracle_create.sql",
openFile(file, s_topNS + "/db/oracleSchema.sql",
IO_WriteOnly | IO_Truncate);
file.close();
openFile(file, s_topNS + "/db/oracleGeneratedCore_create.sql",
......@@ -47,7 +47,7 @@ void CppCppDbCnvWriter::startSQLFile() {
IO_WriteOnly | IO_Truncate);
file.close();
openFile(file, s_topNS + "/db/" + s_topNS + "_postgres_create.sql",
openFile(file, s_topNS + "/db/postgresSchema.sql",
IO_WriteOnly | IO_Truncate);
file.close();
openFile(file, s_topNS + "/db/postgresGeneratedCore_create.sql",
......@@ -90,20 +90,19 @@ void CppCppDbCnvWriter::insertFileintoStream(QTextStream &stream,
void CppCppDbCnvWriter::endSQLFile() {
// Finalizing SQL files for creation/deletion of the database(s)
QFile file;
openFile(file, s_topNS + "/db/" + s_topNS + "_oracle_create.sql",
openFile(file, s_topNS + "/db/oracleSchema.sql",
IO_WriteOnly | IO_Append);
QTextStream streamO(&file);
insertFileintoStream(streamO, s_topNS + "/db/oracleGeneratedCore_create.sql");
insertFileintoStream(streamO, s_topNS + "/db/oracleGeneratedTrailer_create.sql");
insertFileintoStream(streamO, s_topNS + "/db/oracleTrailer.sql");
// don't append oracleTrailer, this will be done at release time
file.close();
openFile(file, s_topNS + "/db/" + s_topNS + "_postgres_create.sql",
openFile(file, s_topNS + "/db/postgresSchema.sql",
IO_WriteOnly | IO_Append);
QTextStream streamP(&file);
insertFileintoStream(streamP, s_topNS + "/db/postgresGeneratedCore_create.sql");
insertFileintoStream(streamP, s_topNS + "/db/postgresGeneratedTrailer_create.sql");
insertFileintoStream(streamP, s_topNS + "/db/postgresTrailer.sql");
file.close();
openFile(file, s_topNS + "/db/" + s_topNS + "_postgres_drop.sql",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment