2008-05-19 15:47:48 +02:00
|
|
|
/*
|
|
|
|
* The contents of this file are subject to the Interbase Public
|
|
|
|
* License Version 1.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy
|
|
|
|
* of the License at http://www.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
|
|
|
* Adriano dos Santos Fernandes - refactored from pass1.cpp, ddl.cpp, dyn*.epp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "firebird.h"
|
|
|
|
#include "../jrd/common.h"
|
|
|
|
#include "../dsql/DdlNodes.h"
|
|
|
|
#include "../jrd/jrd.h"
|
|
|
|
#include "../jrd/cmp_proto.h"
|
|
|
|
#include "../jrd/exe_proto.h"
|
|
|
|
#include "../jrd/met_proto.h"
|
|
|
|
#include "../dsql/metd_proto.h"
|
|
|
|
|
2008-07-03 14:02:54 +02:00
|
|
|
using namespace Firebird;
|
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
namespace Jrd {
|
|
|
|
|
|
|
|
|
|
|
|
DATABASE DB = STATIC "ODS.RDB";
|
|
|
|
|
|
|
|
|
2008-07-03 14:02:54 +02:00
|
|
|
void AlterCharSetNode::print(string& text, Array<dsql_nod*>& nodes) const
|
2008-05-19 15:47:48 +02:00
|
|
|
{
|
|
|
|
text.printf(
|
|
|
|
"alter character set\n"
|
|
|
|
" charSet: %s\n"
|
|
|
|
" defaultCollation: %s\n",
|
|
|
|
charSet.c_str(), defaultCollation.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AlterCharSetNode::execute(thread_db* tdbb, jrd_tra* transaction)
|
|
|
|
{
|
2008-05-24 05:19:52 +02:00
|
|
|
if (compiledStatement && compiledStatement->req_dbb) // do not run in CREATE DATABASE
|
2008-05-19 15:47:48 +02:00
|
|
|
{
|
2008-05-24 05:19:52 +02:00
|
|
|
METD_drop_charset(compiledStatement, charSet);
|
2008-05-19 15:47:48 +02:00
|
|
|
MET_dsql_cache_release(tdbb, SYM_intlsym_charset, charSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
Database* dbb = tdbb->getDatabase();
|
|
|
|
bool charSetFound = false;
|
|
|
|
bool collationFound = false;
|
|
|
|
|
|
|
|
jrd_req* request1 = CMP_find_request(tdbb, drq_m_charset, DYN_REQUESTS);
|
|
|
|
|
|
|
|
FOR (REQUEST_HANDLE request1 TRANSACTION_HANDLE transaction)
|
|
|
|
CS IN RDB$CHARACTER_SETS
|
|
|
|
WITH CS.RDB$CHARACTER_SET_NAME EQ charSet.c_str()
|
2009-01-05 09:48:32 +01:00
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
charSetFound = true;
|
|
|
|
|
|
|
|
if (!DYN_REQUEST(drq_m_charset))
|
|
|
|
DYN_REQUEST(drq_m_charset) = request1;
|
|
|
|
|
|
|
|
jrd_req* request2 = CMP_find_request(tdbb, drq_l_collation, DYN_REQUESTS);
|
|
|
|
|
|
|
|
FOR (REQUEST_HANDLE request2 TRANSACTION_HANDLE transaction)
|
|
|
|
COLL IN RDB$COLLATIONS
|
|
|
|
WITH COLL.RDB$CHARACTER_SET_ID EQ CS.RDB$CHARACTER_SET_ID AND
|
2009-01-05 09:48:32 +01:00
|
|
|
COLL.RDB$COLLATION_NAME EQ defaultCollation.c_str()
|
|
|
|
|
2008-05-19 15:47:48 +02:00
|
|
|
if (!DYN_REQUEST(drq_l_collation))
|
|
|
|
DYN_REQUEST(drq_l_collation) = request2;
|
|
|
|
|
|
|
|
collationFound = true;
|
2009-01-05 09:48:32 +01:00
|
|
|
END_FOR
|
2008-05-19 15:47:48 +02:00
|
|
|
|
|
|
|
if (!DYN_REQUEST(drq_l_collation))
|
|
|
|
DYN_REQUEST(drq_l_collation) = request2;
|
|
|
|
|
|
|
|
if (collationFound)
|
|
|
|
{
|
|
|
|
MODIFY CS
|
|
|
|
CS.RDB$DEFAULT_COLLATE_NAME.NULL = FALSE;
|
|
|
|
strcpy(CS.RDB$DEFAULT_COLLATE_NAME, defaultCollation.c_str());
|
2009-01-05 09:48:32 +01:00
|
|
|
END_MODIFY
|
2008-05-19 15:47:48 +02:00
|
|
|
}
|
2009-01-05 09:48:32 +01:00
|
|
|
END_FOR
|
2008-05-19 15:47:48 +02:00
|
|
|
|
|
|
|
if (!DYN_REQUEST(drq_m_charset))
|
|
|
|
DYN_REQUEST(drq_m_charset) = request1;
|
|
|
|
|
|
|
|
if (!charSetFound)
|
|
|
|
{
|
2008-07-03 14:02:54 +02:00
|
|
|
status_exception::raise(Arg::Gds(isc_charset_not_found) << Arg::Str(charSet));
|
2008-05-19 15:47:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!collationFound)
|
|
|
|
{
|
2009-01-05 09:48:32 +01:00
|
|
|
status_exception::raise(Arg::Gds(isc_collation_not_found) << Arg::Str(defaultCollation) <<
|
|
|
|
Arg::Str(charSet));
|
2008-05-19 15:47:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Jrd
|