MCPcopy Create free account
hub / github.com/apecloud/myduckserver / DropCheck

Method DropCheck

catalog/table.go:986–1005  ·  view source on GitHub ↗

DropCheck implements sql.CheckAlterableTable.

(ctx *sql.Context, checkName string)

Source from the content-addressed store, hash-verified

984func (t *Table) PeekNextAutoIncrementValue(ctx *sql.Context) (uint64, error) {
985 t.mu.RLock()
986 defer t.mu.RUnlock()
987
988 if t.comment.Meta.Sequence == "" {
989 return 0, sql.ErrNoAutoIncrementCol
990 }
991 return t.getNextAutoIncrementValue(ctx)
992}
993
994func (t *Table) getNextAutoIncrementValue(ctx *sql.Context) (uint64, error) {
995 // For PeekNextAutoIncrementValue, we want to see what the next value would be
996 // without actually incrementing. We can do this by getting currval + 1.
997 var val uint64
998 err := adapter.QueryRowCatalog(ctx, `SELECT currval('`+t.comment.Meta.Sequence+`') + 1`).Scan(&val)
999 if err != nil {
1000 // https://duckdb.org/docs/sql/statements/create_sequence.html#selecting-the-current-value
1001 // > Note that the nextval function must have already been called before calling currval,
1002 // > otherwise a Serialization Error (sequence is not yet defined in this session) will be thrown.
1003 if !strings.Contains(err.Error(), "sequence is not yet defined in this session") {
1004 return 0, ErrDuckDB.New(err)
1005 }
1006 // If the sequence has not been used yet, we can get the start value from the sequence.
1007 // See getCreateSequence() for the sequence name format.
1008 err = adapter.QueryRowCatalog(ctx, `SELECT start_value FROM duckdb_sequences() WHERE concat(schema_name, '."', sequence_name, '"') = '`+t.comment.Meta.Sequence+`'`).Scan(&val)

Callers

nothing calls this directly

Calls 1

updateExtraTableInfoMethod · 0.95

Tested by

no test coverage detected