mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 16:43:03 +01:00
Ability to create an inactive index (#8091)
* Ability to create an inactive index * Extract inactive indices in dialect 1
This commit is contained in:
parent
a8f5bdbe1c
commit
67d8e39e44
@ -709,3 +709,12 @@ CREATE PACKAGE BODY [IF NOT EXISTS] ...
|
|||||||
CREATE [GLOBAL] MAPPING [IF NOT EXISTS] ...
|
CREATE [GLOBAL] MAPPING [IF NOT EXISTS] ...
|
||||||
ALTER TABLE <table> ADD [IF NOT EXISTS] <column name> ...
|
ALTER TABLE <table> ADD [IF NOT EXISTS] <column name> ...
|
||||||
ALTER TABLE <table> ADD CONSTRAINT [IF NOT EXISTS] <constraint name> ...
|
ALTER TABLE <table> ADD CONSTRAINT [IF NOT EXISTS] <constraint name> ...
|
||||||
|
|
||||||
|
3) Creation of an inactive index
|
||||||
|
|
||||||
|
CREATE [UNIQUE] [ASC[ENDING] | DESC[ENDING]]
|
||||||
|
INDEX indexname [{ACTIVE | INACTIVE}]
|
||||||
|
ON tablename {(col [, col ...]) | COMPUTED BY (<expression>)}
|
||||||
|
[WHERE <search_condition>]
|
||||||
|
|
||||||
|
'isql -x' generates script accordingly.
|
||||||
|
@ -10062,7 +10062,7 @@ void CreateIndexNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
|
|||||||
definition.relation = relation->dsqlName;
|
definition.relation = relation->dsqlName;
|
||||||
definition.unique = unique;
|
definition.unique = unique;
|
||||||
definition.descending = descending;
|
definition.descending = descending;
|
||||||
definition.inactive = false;
|
definition.inactive = !active;
|
||||||
|
|
||||||
if (columns)
|
if (columns)
|
||||||
{
|
{
|
||||||
|
@ -1790,6 +1790,7 @@ public:
|
|||||||
MetaName name;
|
MetaName name;
|
||||||
bool unique;
|
bool unique;
|
||||||
bool descending;
|
bool descending;
|
||||||
|
bool active;
|
||||||
NestConst<RelationSourceNode> relation;
|
NestConst<RelationSourceNode> relation;
|
||||||
NestConst<ValueListNode> columns;
|
NestConst<ValueListNode> columns;
|
||||||
NestConst<ValueSourceClause> computed;
|
NestConst<ValueSourceClause> computed;
|
||||||
|
@ -1546,18 +1546,19 @@ create_clause
|
|||||||
node->createIfNotExistsOnly = $2;
|
node->createIfNotExistsOnly = $2;
|
||||||
$$ = node;
|
$$ = node;
|
||||||
}
|
}
|
||||||
| unique_opt order_direction INDEX if_not_exists_opt symbol_index_name ON simple_table_name
|
| unique_opt order_direction INDEX if_not_exists_opt symbol_index_name index_active_opt ON simple_table_name
|
||||||
{
|
{
|
||||||
const auto node = newNode<CreateIndexNode>(*$5);
|
const auto node = newNode<CreateIndexNode>(*$5);
|
||||||
|
node->active = $6;
|
||||||
node->unique = $1;
|
node->unique = $1;
|
||||||
node->descending = $2;
|
node->descending = $2;
|
||||||
node->createIfNotExistsOnly = $4;
|
node->createIfNotExistsOnly = $4;
|
||||||
node->relation = $7;
|
node->relation = $8;
|
||||||
$$ = node;
|
$$ = node;
|
||||||
}
|
}
|
||||||
index_definition(static_cast<CreateIndexNode*>($8))
|
index_definition(static_cast<CreateIndexNode*>($9))
|
||||||
{
|
{
|
||||||
$$ = $8;
|
$$ = $9;
|
||||||
}
|
}
|
||||||
| FUNCTION if_not_exists_opt function_clause
|
| FUNCTION if_not_exists_opt function_clause
|
||||||
{
|
{
|
||||||
@ -1753,6 +1754,12 @@ alter_exception_clause
|
|||||||
|
|
||||||
// CREATE INDEX
|
// CREATE INDEX
|
||||||
|
|
||||||
|
%type <boolVal> index_active_opt
|
||||||
|
index_active_opt
|
||||||
|
: /* nothing */ { $$ = true; }
|
||||||
|
| index_active { $$ = $1; }
|
||||||
|
;
|
||||||
|
|
||||||
%type <boolVal> unique_opt
|
%type <boolVal> unique_opt
|
||||||
unique_opt
|
unique_opt
|
||||||
: /* nothing */ { $$ = false; }
|
: /* nothing */ { $$ = false; }
|
||||||
@ -4676,8 +4683,16 @@ drop_behaviour
|
|||||||
|
|
||||||
%type <ddlNode> alter_index_clause
|
%type <ddlNode> alter_index_clause
|
||||||
alter_index_clause
|
alter_index_clause
|
||||||
: symbol_index_name ACTIVE { $$ = newNode<AlterIndexNode>(*$1, true); }
|
: symbol_index_name index_active
|
||||||
| symbol_index_name INACTIVE { $$ = newNode<AlterIndexNode>(*$1, false); }
|
{
|
||||||
|
$$ = newNode<AlterIndexNode>(*$1, $2);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
%type <boolVal> index_active
|
||||||
|
index_active
|
||||||
|
: ACTIVE { $$ = true; }
|
||||||
|
| INACTIVE { $$ = false; }
|
||||||
;
|
;
|
||||||
|
|
||||||
%type <ddlNode> alter_udf_clause
|
%type <ddlNode> alter_udf_clause
|
||||||
|
@ -3337,17 +3337,19 @@ static void list_indexes()
|
|||||||
{
|
{
|
||||||
IUTILS_copy_SQL_id (IDX.RDB$INDEX_NAME, SQL_identifier, DBL_QUOTE);
|
IUTILS_copy_SQL_id (IDX.RDB$INDEX_NAME, SQL_identifier, DBL_QUOTE);
|
||||||
IUTILS_copy_SQL_id (IDX.RDB$RELATION_NAME, SQL_identifier2, DBL_QUOTE);
|
IUTILS_copy_SQL_id (IDX.RDB$RELATION_NAME, SQL_identifier2, DBL_QUOTE);
|
||||||
isqlGlob.printf("CREATE%s%s INDEX %s ON %s",
|
isqlGlob.printf("CREATE%s%s INDEX %s%s ON %s",
|
||||||
(IDX.RDB$UNIQUE_FLAG ? " UNIQUE" : ""),
|
(IDX.RDB$UNIQUE_FLAG ? " UNIQUE" : ""),
|
||||||
(IDX.RDB$INDEX_TYPE ? " DESCENDING" : ""),
|
(IDX.RDB$INDEX_TYPE ? " DESCENDING" : ""),
|
||||||
SQL_identifier,
|
SQL_identifier,
|
||||||
|
(IDX.RDB$INDEX_INACTIVE ? " INACTIVE" : ""),
|
||||||
SQL_identifier2);
|
SQL_identifier2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
isqlGlob.printf("CREATE%s%s INDEX %s ON %s",
|
isqlGlob.printf("CREATE%s%s INDEX %s%s ON %s",
|
||||||
(IDX.RDB$UNIQUE_FLAG ? " UNIQUE" : ""),
|
(IDX.RDB$UNIQUE_FLAG ? " UNIQUE" : ""),
|
||||||
(IDX.RDB$INDEX_TYPE ? " DESCENDING" : ""),
|
(IDX.RDB$INDEX_TYPE ? " DESCENDING" : ""),
|
||||||
IDX.RDB$INDEX_NAME,
|
IDX.RDB$INDEX_NAME,
|
||||||
|
(IDX.RDB$INDEX_INACTIVE ? " INACTIVE" : ""),
|
||||||
IDX.RDB$RELATION_NAME);
|
IDX.RDB$RELATION_NAME);
|
||||||
|
|
||||||
// Get index expression or column names
|
// Get index expression or column names
|
||||||
|
Loading…
Reference in New Issue
Block a user