mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 06:03:02 +01:00
Fixed problem with ALTER SEQUENCE.
This commit is contained in:
parent
913c435667
commit
128ec5aee0
@ -39,28 +39,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// NullableClear specializations.
|
|
||||||
|
|
||||||
template <>
|
|
||||||
class NullableClear<Firebird::string> // string especialization for NullableClear
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void clear(Firebird::string& v)
|
|
||||||
{
|
|
||||||
v = "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
class NullableClear<Firebird::MetaName> // MetaName especialization for NullableClear
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void clear(Firebird::MetaName& v)
|
|
||||||
{
|
|
||||||
v = "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Nullable support without constructor, to allow usage in unions (used in the parser).
|
// Nullable support without constructor, to allow usage in unions (used in the parser).
|
||||||
template <typename T> class BaseNullable
|
template <typename T> class BaseNullable
|
||||||
@ -93,6 +71,39 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// NullableClear specializations.
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class NullableClear<Firebird::string> // string especialization for NullableClear
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void clear(Firebird::string& v)
|
||||||
|
{
|
||||||
|
v = "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
class NullableClear<Firebird::MetaName> // MetaName especialization for NullableClear
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void clear(Firebird::MetaName& v)
|
||||||
|
{
|
||||||
|
v = "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class NullableClear<BaseNullable<T> >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void clear(BaseNullable<T>& v)
|
||||||
|
{
|
||||||
|
v.specified = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Actual Nullable template.
|
// Actual Nullable template.
|
||||||
template <typename T> class Nullable : public BaseNullable<T>
|
template <typename T> class Nullable : public BaseNullable<T>
|
||||||
{
|
{
|
||||||
|
@ -4941,7 +4941,7 @@ bool CreateAlterSequenceNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch*
|
|||||||
|
|
||||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE, DDL_TRIGGER_ALTER_SEQUENCE, name);
|
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE, DDL_TRIGGER_ALTER_SEQUENCE, name);
|
||||||
|
|
||||||
fb_assert(value.specified);
|
fb_assert(restartSpecified && value.specified);
|
||||||
const SINT64 val = value.specified ? value.value : 0;
|
const SINT64 val = value.specified ? value.value : 0;
|
||||||
if (step.specified)
|
if (step.specified)
|
||||||
{
|
{
|
||||||
@ -4981,8 +4981,7 @@ bool CreateAlterSequenceNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch*
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SLONG id = X.RDB$GENERATOR_ID;
|
const SLONG id = X.RDB$GENERATOR_ID;
|
||||||
const SINT64 val = value.specified ?
|
|
||||||
value.value : (!X.RDB$INITIAL_VALUE.NULL ? X.RDB$INITIAL_VALUE : 0);
|
|
||||||
if (step.specified)
|
if (step.specified)
|
||||||
{
|
{
|
||||||
const SLONG newStep = step.value;
|
const SLONG newStep = step.value;
|
||||||
@ -4997,7 +4996,13 @@ bool CreateAlterSequenceNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction->getGenIdCache()->put(id, val);
|
if (restartSpecified)
|
||||||
|
{
|
||||||
|
const SINT64 val = value.specified ?
|
||||||
|
value.value : (!X.RDB$INITIAL_VALUE.NULL ? X.RDB$INITIAL_VALUE : 0);
|
||||||
|
transaction->getGenIdCache()->put(id, val);
|
||||||
|
}
|
||||||
|
|
||||||
dsc desc;
|
dsc desc;
|
||||||
desc.makeText((USHORT) name.length(), ttype_metadata, (UCHAR*) name.c_str());
|
desc.makeText((USHORT) name.length(), ttype_metadata, (UCHAR*) name.c_str());
|
||||||
DFW_post_work(transaction, dfw_set_generator, &desc, id);
|
DFW_post_work(transaction, dfw_set_generator, &desc, id);
|
||||||
|
@ -916,6 +916,7 @@ public:
|
|||||||
create(true),
|
create(true),
|
||||||
alter(false),
|
alter(false),
|
||||||
legacy(false),
|
legacy(false),
|
||||||
|
restartSpecified(false),
|
||||||
name(pool, aName),
|
name(pool, aName),
|
||||||
value(aValue),
|
value(aValue),
|
||||||
step(aStep)
|
step(aStep)
|
||||||
@ -959,6 +960,7 @@ public:
|
|||||||
bool create;
|
bool create;
|
||||||
bool alter;
|
bool alter;
|
||||||
bool legacy;
|
bool legacy;
|
||||||
|
bool restartSpecified;
|
||||||
const Firebird::MetaName name;
|
const Firebird::MetaName name;
|
||||||
const BaseNullable<SINT64> value;
|
const BaseNullable<SINT64> value;
|
||||||
const BaseNullable<SLONG> step;
|
const BaseNullable<SLONG> step;
|
||||||
|
@ -607,6 +607,7 @@ using namespace Firebird;
|
|||||||
SINT64 int64Val;
|
SINT64 int64Val;
|
||||||
FB_UINT64 uint64Val;
|
FB_UINT64 uint64Val;
|
||||||
BaseNullable<SINT64> nullableInt64Val;
|
BaseNullable<SINT64> nullableInt64Val;
|
||||||
|
BaseNullable<BaseNullable<SINT64> > nullableNullableInt64Val;
|
||||||
BaseNullable<FB_UINT64> nullableUint64Val;
|
BaseNullable<FB_UINT64> nullableUint64Val;
|
||||||
Jrd::ScaledNumber scaledNumber;
|
Jrd::ScaledNumber scaledNumber;
|
||||||
UCHAR blrOp;
|
UCHAR blrOp;
|
||||||
@ -1508,6 +1509,7 @@ replace_sequence_clause
|
|||||||
{
|
{
|
||||||
CreateAlterSequenceNode* node = newNode<CreateAlterSequenceNode>(*$1, $2, $3);
|
CreateAlterSequenceNode* node = newNode<CreateAlterSequenceNode>(*$1, $2, $3);
|
||||||
node->alter = true;
|
node->alter = true;
|
||||||
|
node->restartSpecified = true;
|
||||||
$$ = node;
|
$$ = node;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -1524,9 +1526,10 @@ alter_sequence_clause
|
|||||||
{
|
{
|
||||||
if (!$2.specified && !$3.specified)
|
if (!$2.specified && !$3.specified)
|
||||||
yyerrorIncompleteCmd();
|
yyerrorIncompleteCmd();
|
||||||
CreateAlterSequenceNode* node = newNode<CreateAlterSequenceNode>(*$1, $2, $3);
|
CreateAlterSequenceNode* node = newNode<CreateAlterSequenceNode>(*$1, $2.value, $3);
|
||||||
node->create = false;
|
node->create = false;
|
||||||
node->alter = true;
|
node->alter = true;
|
||||||
|
node->restartSpecified = $2.specified;
|
||||||
$$ = node;
|
$$ = node;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -1537,10 +1540,10 @@ restart_value_opt
|
|||||||
| RESTART WITH sequence_value { $$ = Nullable<SINT64>::val($3); }
|
| RESTART WITH sequence_value { $$ = Nullable<SINT64>::val($3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
%type <nullableInt64Val> restart_value_opt2
|
%type <nullableNullableInt64Val> restart_value_opt2
|
||||||
restart_value_opt2
|
restart_value_opt2
|
||||||
: /* nothing */ { $$ = Nullable<SINT64>::empty(); }
|
: /* nothing */ { $$ = Nullable<BaseNullable<SINT64> >::empty(); }
|
||||||
| restart_value_opt
|
| restart_value_opt { $$ = Nullable<BaseNullable<SINT64> > ::val($1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -1553,6 +1556,7 @@ set_generator_clause
|
|||||||
node->create = false;
|
node->create = false;
|
||||||
node->alter = true;
|
node->alter = true;
|
||||||
node->legacy = true;
|
node->legacy = true;
|
||||||
|
node->restartSpecified = true;
|
||||||
$$ = node;
|
$$ = node;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
Loading…
Reference in New Issue
Block a user