pgerror.go 994 B

12345678910111213141516171819202122232425262728
  1. // Package pgerror holds SQLSTATE metadata and sentinel errors shared by the
  2. // parser, executor, and protocol servers.
  3. package pgerror
  4. import (
  5. "errors"
  6. "fmt"
  7. )
  8. // SQLSTATE codes used by PizzaSQL's protocol and HTTP surfaces.
  9. const (
  10. CodeFeatureNotSupported = "0A000"
  11. CodeUniqueViolation = "23505"
  12. CodeSerializationFailure = "40001"
  13. CodeSyntaxError = "42601"
  14. CodeInternalError = "XX000"
  15. )
  16. // ErrFeatureNotSupported marks SQL that PizzaSQL intentionally rejects instead
  17. // of accepting with different semantics. Protocol layers map it to SQLSTATE
  18. // 0A000 (feature_not_supported) rather than a generic syntax or internal error.
  19. var ErrFeatureNotSupported = errors.New("feature not supported")
  20. // Unsupported returns an error that wraps ErrFeatureNotSupported with a
  21. // client-facing explanation and migration hint.
  22. func Unsupported(format string, args ...interface{}) error {
  23. return fmt.Errorf("%w: %s", ErrFeatureNotSupported, fmt.Sprintf(format, args...))
  24. }