diff --git a/doc/sql.extensions/README.ddl.txt b/doc/sql.extensions/README.ddl.txt
index d508aacaf7..19ca28c3c8 100644
--- a/doc/sql.extensions/README.ddl.txt
+++ b/doc/sql.extensions/README.ddl.txt
@@ -709,3 +709,12 @@ CREATE PACKAGE BODY [IF NOT EXISTS] ...
CREATE [GLOBAL] MAPPING [IF NOT EXISTS] ...
ALTER TABLE
ADD [IF NOT EXISTS] ...
ALTER TABLE ADD CONSTRAINT [IF NOT EXISTS] ...
+
+3) Creation of an inactive index
+
+CREATE [UNIQUE] [ASC[ENDING] | DESC[ENDING]]
+ INDEX indexname [{ACTIVE | INACTIVE}]
+ ON tablename {(col [, col ...]) | COMPUTED BY ()}
+ [WHERE ]
+
+'isql -x' generates script accordingly.
diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp
index 688d54ab0c..0fa5cce0bb 100644
--- a/src/dsql/DdlNodes.epp
+++ b/src/dsql/DdlNodes.epp
@@ -10062,7 +10062,7 @@ void CreateIndexNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
definition.relation = relation->dsqlName;
definition.unique = unique;
definition.descending = descending;
- definition.inactive = false;
+ definition.inactive = !active;
if (columns)
{
diff --git a/src/dsql/DdlNodes.h b/src/dsql/DdlNodes.h
index 554a39ca35..aec9dfdb48 100644
--- a/src/dsql/DdlNodes.h
+++ b/src/dsql/DdlNodes.h
@@ -1790,6 +1790,7 @@ public:
MetaName name;
bool unique;
bool descending;
+ bool active;
NestConst relation;
NestConst columns;
NestConst computed;
diff --git a/src/dsql/parse.y b/src/dsql/parse.y
index 2eac7d7031..a299f9c4b0 100644
--- a/src/dsql/parse.y
+++ b/src/dsql/parse.y
@@ -1546,18 +1546,19 @@ create_clause
node->createIfNotExistsOnly = $2;
$$ = 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(*$5);
+ node->active = $6;
node->unique = $1;
node->descending = $2;
node->createIfNotExistsOnly = $4;
- node->relation = $7;
+ node->relation = $8;
$$ = node;
}
- index_definition(static_cast($8))
+ index_definition(static_cast($9))
{
- $$ = $8;
+ $$ = $9;
}
| FUNCTION if_not_exists_opt function_clause
{
@@ -1753,6 +1754,12 @@ alter_exception_clause
// CREATE INDEX
+%type index_active_opt
+index_active_opt
+ : /* nothing */ { $$ = true; }
+ | index_active { $$ = $1; }
+ ;
+
%type unique_opt
unique_opt
: /* nothing */ { $$ = false; }
@@ -4676,8 +4683,16 @@ drop_behaviour
%type alter_index_clause
alter_index_clause
- : symbol_index_name ACTIVE { $$ = newNode(*$1, true); }
- | symbol_index_name INACTIVE { $$ = newNode(*$1, false); }
+ : symbol_index_name index_active
+ {
+ $$ = newNode(*$1, $2);
+ }
+ ;
+
+%type index_active
+index_active
+ : ACTIVE { $$ = true; }
+ | INACTIVE { $$ = false; }
;
%type alter_udf_clause
diff --git a/src/isql/extract.epp b/src/isql/extract.epp
index d1aa3b2db4..c281cae6b8 100644
--- a/src/isql/extract.epp
+++ b/src/isql/extract.epp
@@ -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$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$INDEX_TYPE ? " DESCENDING" : ""),
SQL_identifier,
+ (IDX.RDB$INDEX_INACTIVE ? " INACTIVE" : ""),
SQL_identifier2);
}
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$INDEX_TYPE ? " DESCENDING" : ""),
IDX.RDB$INDEX_NAME,
+ (IDX.RDB$INDEX_INACTIVE ? " INACTIVE" : ""),
IDX.RDB$RELATION_NAME);
// Get index expression or column names