8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 00:03:02 +01:00
This commit is contained in:
Dmitry Yemanov 2020-04-06 15:31:54 +03:00
parent 76fb2b39b2
commit eb7c9f3140
2 changed files with 14 additions and 21 deletions

View File

@ -939,7 +939,7 @@ void DsqlDdlRequest::dsqlPass(thread_db* tdbb, DsqlCompilerScratch* scratch, boo
rethrowDdlException(ex, false);
}
if (scratch->getAttachment()->dbb_read_only)
if (dbb->readOnly())
ERRD_post(Arg::Gds(isc_read_only_database));
// In read-only replica, only replicator is allowed to execute DDL.
@ -951,12 +951,14 @@ void DsqlDdlRequest::dsqlPass(thread_db* tdbb, DsqlCompilerScratch* scratch, boo
ERRD_post(Arg::Gds(isc_read_only_trans));
}
const auto dbDialect =
(dbb->dbb_flags & DBB_DB_SQL_dialect_3) ? SQL_DIALECT_V6 : SQL_DIALECT_V5;
if ((scratch->flags & DsqlCompilerScratch::FLAG_AMBIGUOUS_STMT) &&
scratch->getAttachment()->dbb_db_SQL_dialect != scratch->clientDialect)
dbDialect != scratch->clientDialect)
{
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-817) <<
Arg::Gds(isc_ddl_not_allowed_by_db_sql_dial) <<
Arg::Num(scratch->getAttachment()->dbb_db_SQL_dialect));
Arg::Gds(isc_ddl_not_allowed_by_db_sql_dial) << Arg::Num(dbDialect));
}
if (scratch->clientDialect > SQL_DIALECT_V5)
@ -1120,15 +1122,6 @@ static dsql_dbb* init(thread_db* tdbb, Jrd::Attachment* attachment)
INI_init_dsql(tdbb, database);
Database* const dbb = tdbb->getDatabase();
database->dbb_db_SQL_dialect =
(dbb->dbb_flags & DBB_DB_SQL_dialect_3) ? SQL_DIALECT_V6 : SQL_DIALECT_V5;
database->dbb_ods_version = dbb->dbb_ods_version;
database->dbb_minor_version = dbb->dbb_minor_version;
database->dbb_read_only = dbb->readOnly();
#ifdef DSQL_DEBUG
DSQL_debug = Config::getTraceDSQL();
#endif
@ -1473,6 +1466,8 @@ static dsql_req* prepareRequest(thread_db* tdbb, dsql_dbb* database, jrd_tra* tr
static dsql_req* prepareStatement(thread_db* tdbb, dsql_dbb* database, jrd_tra* transaction,
ULONG textLength, const TEXT* text, USHORT clientDialect, bool isInternalRequest)
{
Database* const dbb = tdbb->getDatabase();
if (text && textLength == 0)
textLength = static_cast<ULONG>(strlen(text));
@ -1534,14 +1529,18 @@ static dsql_req* prepareStatement(thread_db* tdbb, dsql_dbb* database, jrd_tra*
if (isInternalRequest)
scratch->flags |= DsqlCompilerScratch::FLAG_INTERNAL_REQUEST;
const auto dbDialect =
(dbb->dbb_flags & DBB_DB_SQL_dialect_3) ? SQL_DIALECT_V6 : SQL_DIALECT_V5;
const auto charSetId = database->dbb_attachment->att_charset;
string transformedText;
{ // scope to delete parser before the scratch pool is gone
Jrd::ContextPoolHolder scratchContext(tdbb, scratchPool);
Parser parser(tdbb, *scratchPool, scratch, clientDialect,
scratch->getAttachment()->dbb_db_SQL_dialect, text, textLength,
tdbb->getAttachment()->att_charset);
dbDialect, text, textLength, charSetId);
// Parse the SQL statement. If it croaks, return
request = parser.parse();
@ -1557,8 +1556,6 @@ static dsql_req* prepareStatement(thread_db* tdbb, dsql_dbb* database, jrd_tra*
request->req_transaction = scratch->getTransaction();
request->statement = scratch->getStatement();
const SSHORT charSetId = database->dbb_attachment->att_charset;
// If the attachment charset is NONE, replace non-ASCII characters by question marks, so
// that engine internals doesn't receive non-mappeable data to UTF8. If an attachment
// charset is used, validate the string.

View File

@ -144,10 +144,6 @@ public:
Attachment* dbb_attachment;
Firebird::MetaName dbb_dfl_charset;
bool dbb_no_charset;
bool dbb_read_only;
USHORT dbb_db_SQL_dialect;
USHORT dbb_ods_version; // major ODS version number
USHORT dbb_minor_version; // minor ODS version number
explicit dsql_dbb(MemoryPool& p)
: dbb_relations(p),