B compatibility support sql_mode NO_AUTO_VALUE_ON_ZERO
This commit is contained in:
@ -33380,8 +33380,11 @@ static int128 EvaluateAutoIncrement(Relation rel, TupleDesc desc, AttrNumber att
|
||||
autoinc = datum2autoinc(cons_autoinc, *value);
|
||||
modify_value = (autoinc == 0);
|
||||
}
|
||||
/* When datum is NULL/0, auto increase */
|
||||
if (autoinc == 0) {
|
||||
/*
|
||||
* By default, when datum is NULL/0, auto increase;
|
||||
* If NO_AUTO_VALUE_ON_ZERO is set, auto increase only when datum is NULL.
|
||||
*/
|
||||
if (*is_null || (autoinc == 0 && !CheckPluginNoAutoValueOnZero())) {
|
||||
if (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP) {
|
||||
autoinc = tmptable_autoinc_nextval(rel->rd_rel->relfilenode, cons_autoinc->next);
|
||||
} else {
|
||||
|
||||
@ -1669,8 +1669,11 @@ Tuple ExecAutoIncrement(Relation rel, EState* estate, TupleTableSlot* slot, Tupl
|
||||
autoinc = datum2autoinc(cons_autoinc, datum);
|
||||
modify_tuple = (autoinc == 0);
|
||||
}
|
||||
/* When datum is NULL/0, auto increase */
|
||||
if (autoinc == 0) {
|
||||
|
||||
/* By default, when datum is NULL/0, auto increase;
|
||||
* If NO_AUTO_VALUE_ON_ZERO is set, auto increase only when datum is NULL.
|
||||
*/
|
||||
if (is_null || (autoinc == 0 && !CheckPluginNoAutoValueOnZero())) {
|
||||
if (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP) {
|
||||
autoinc = tmptable_autoinc_nextval(rel->rd_rel->relfilenode, cons_autoinc->next);
|
||||
} else {
|
||||
|
||||
@ -746,6 +746,14 @@ extern inline bool CheckPluginReplaceNull()
|
||||
((replaceNullOrNotFunc)(u_sess->hook_cxt.replaceNullOrNotHook))() : false;
|
||||
}
|
||||
|
||||
typedef bool (*noAutoValueOnZeroFunc)();
|
||||
|
||||
extern inline bool CheckPluginNoAutoValueOnZero()
|
||||
{
|
||||
return u_sess->hook_cxt.noAutoValueOnZeroHook != NULL ?
|
||||
((noAutoValueOnZeroFunc)(u_sess->hook_cxt.noAutoValueOnZeroHook))() : false;
|
||||
}
|
||||
|
||||
// AutoMutexLock
|
||||
// Auto object for non-recursive pthread_mutex_t lock
|
||||
//
|
||||
|
||||
@ -2959,6 +2959,7 @@ typedef struct knl_u_hook_context {
|
||||
void *pluginPlannerHook;
|
||||
void *groupingplannerHook;
|
||||
void *replaceNullOrNotHook;
|
||||
void *noAutoValueOnZeroHook;
|
||||
void *nullsMinimalPolicyHook;
|
||||
void *getIgnoreKeywordTokenHook;
|
||||
void *modifyTypeForPartitionKeyHook;
|
||||
|
||||
Reference in New Issue
Block a user