MCPcopy
hub / github.com/pingcap/tidb / HandleBadNull

Method HandleBadNull

pkg/table/column.go:524–536  ·  view source on GitHub ↗

HandleBadNull handles the bad null error. When caller is LOAD DATA, `rowCntInLoadData` should be greater than 0 the error is ErrWarnNullToNotnull. Otherwise, the error is ErrColumnCantNull. If BadNullAsWarning is true, it will append the error as a warning, else return the error.

(
	ec errctx.Context,
	d *types.Datum,
	rowCntInLoadData uint64)

Source from the content-addressed store, hash-verified

522// Otherwise, the error is ErrColumnCantNull.
523// If BadNullAsWarning is true, it will append the error as a warning, else return the error.
524func (c *Column) HandleBadNull(
525 ec errctx.Context,
526 d *types.Datum,
527 rowCntInLoadData uint64) error {
528 if err := c.CheckNotNull(d, rowCntInLoadData); err != nil {
529 if ec.HandleError(err) == nil {
530 *d = GetZeroValue(c.ToInfo())
531 return nil
532 }
533 return err
534 }
535 return nil
536}
537
538// IsPKHandleColumn checks if the column is primary key handle column.
539func (c *Column) IsPKHandleColumn(tbInfo *model.TableInfo) bool {

Callers 4

TestHandleBadNullFunction · 0.80
updateRecordFunction · 0.80
fillRowMethod · 0.80
getActualDatumMethod · 0.80

Calls 4

CheckNotNullMethod · 0.95
ToInfoMethod · 0.95
GetZeroValueFunction · 0.85
HandleErrorMethod · 0.45

Tested by 1

TestHandleBadNullFunction · 0.64