MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / NewDCollatedString

Function NewDCollatedString

pkg/sql/sem/tree/datum.go:1364–1379  ·  view source on GitHub ↗

NewDCollatedString is a helper routine to create a *DCollatedString. Panics if locale is invalid. Not safe for concurrent use.

(
	contents string, locale string, env *CollationEnvironment,
)

Source from the content-addressed store, hash-verified

1362// NewDCollatedString is a helper routine to create a *DCollatedString. Panics
1363// if locale is invalid. Not safe for concurrent use.
1364func NewDCollatedString(
1365 contents string, locale string, env *CollationEnvironment,
1366) (*DCollatedString, error) {
1367 entry, err := env.getCacheEntry(locale)
1368 if err != nil {
1369 return nil, err
1370 }
1371 if env.buffer == nil {
1372 env.buffer = &collate.Buffer{}
1373 }
1374 key := entry.collator.KeyFromString(env.buffer, contents)
1375 d := DCollatedString{contents, entry.locale, make([]byte, len(key))}
1376 copy(d.Key, key)
1377 env.buffer.Reset()
1378 return &d, nil
1379}
1380
1381// AsDCollatedString attempts to retrieve a DString from an Expr, returning a AsDCollatedString and
1382// a flag signifying whether the assertion was successful. The function should

Callers 4

NewDefaultDatumFunction · 0.85
AdjustValueToTypeFunction · 0.85
ParseAndRequireStringFunction · 0.85
NewDCollatedStringMethod · 0.85

Calls 2

getCacheEntryMethod · 0.80
ResetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…