github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/internal/s3select/unused-errors.go (about)

     1  //go:build ignore
     2  // +build ignore
     3  
     4  // Copyright (c) 2015-2021 MinIO, Inc.
     5  //
     6  // This file is part of MinIO Object Storage stack
     7  //
     8  // This program is free software: you can redistribute it and/or modify
     9  // it under the terms of the GNU Affero General Public License as published by
    10  // the Free Software Foundation, either version 3 of the License, or
    11  // (at your option) any later version.
    12  //
    13  // This program is distributed in the hope that it will be useful
    14  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  // GNU Affero General Public License for more details.
    17  //
    18  // You should have received a copy of the GNU Affero General Public License
    19  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    20  
    21  package s3select
    22  
    23  // /////////////////////////////////////////////////////////////////////
    24  //
    25  //	Validation errors.
    26  //
    27  // /////////////////////////////////////////////////////////////////////
    28  func errExpressionTooLong(err error) *s3Error {
    29  	return &s3Error{
    30  		code:       "ExpressionTooLong",
    31  		message:    "The SQL expression is too long: The maximum byte-length for the SQL expression is 256 KB.",
    32  		statusCode: 400,
    33  		cause:      err,
    34  	}
    35  }
    36  
    37  func errColumnTooLong(err error) *s3Error {
    38  	return &s3Error{
    39  		code:       "ColumnTooLong",
    40  		message:    "The length of a column in the result is greater than maxCharsPerColumn of 1 MB.",
    41  		statusCode: 400,
    42  		cause:      err,
    43  	}
    44  }
    45  
    46  func errOverMaxColumn(err error) *s3Error {
    47  	return &s3Error{
    48  		code:       "OverMaxColumn",
    49  		message:    "The number of columns in the result is greater than the maximum allowable number of columns.",
    50  		statusCode: 400,
    51  		cause:      err,
    52  	}
    53  }
    54  
    55  func errOverMaxRecordSize(err error) *s3Error {
    56  	return &s3Error{
    57  		code:       "OverMaxRecordSize",
    58  		message:    "The length of a record in the input or result is greater than maxCharsPerRecord of 1 MB.",
    59  		statusCode: 400,
    60  		cause:      err,
    61  	}
    62  }
    63  
    64  func errInvalidColumnIndex(err error) *s3Error {
    65  	return &s3Error{
    66  		code:       "InvalidColumnIndex",
    67  		message:    "Column index in the SQL expression is invalid.",
    68  		statusCode: 400,
    69  		cause:      err,
    70  	}
    71  }
    72  
    73  func errInvalidTextEncoding(err error) *s3Error {
    74  	return &s3Error{
    75  		code:       "InvalidTextEncoding",
    76  		message:    "Invalid encoding type. Only UTF-8 encoding is supported.",
    77  		statusCode: 400,
    78  		cause:      err,
    79  	}
    80  }
    81  
    82  func errInvalidTableAlias(err error) *s3Error {
    83  	return &s3Error{
    84  		code:       "InvalidTableAlias",
    85  		message:    "The SQL expression contains an invalid table alias.",
    86  		statusCode: 400,
    87  		cause:      err,
    88  	}
    89  }
    90  
    91  func errUnsupportedSyntax(err error) *s3Error {
    92  	return &s3Error{
    93  		code:       "UnsupportedSyntax",
    94  		message:    "Encountered invalid syntax.",
    95  		statusCode: 400,
    96  		cause:      err,
    97  	}
    98  }
    99  
   100  func errAmbiguousFieldName(err error) *s3Error {
   101  	return &s3Error{
   102  		code:       "AmbiguousFieldName",
   103  		message:    "Field name matches to multiple fields in the file. Check the SQL expression and the file, and try again.",
   104  		statusCode: 400,
   105  		cause:      err,
   106  	}
   107  }
   108  
   109  func errIntegerOverflow(err error) *s3Error {
   110  	return &s3Error{
   111  		code:       "IntegerOverflow",
   112  		message:    "Integer overflow or underflow in the SQL expression.",
   113  		statusCode: 400,
   114  		cause:      err,
   115  	}
   116  }
   117  
   118  func errIllegalSQLFunctionArgument(err error) *s3Error {
   119  	return &s3Error{
   120  		code:       "IllegalSqlFunctionArgument",
   121  		message:    "Illegal argument was used in the SQL function.",
   122  		statusCode: 400,
   123  		cause:      err,
   124  	}
   125  }
   126  
   127  func errMultipleDataSourcesUnsupported(err error) *s3Error {
   128  	return &s3Error{
   129  		code:       "MultipleDataSourcesUnsupported",
   130  		message:    "Multiple data sources are not supported.",
   131  		statusCode: 400,
   132  		cause:      err,
   133  	}
   134  }
   135  
   136  func errMissingHeaders(err error) *s3Error {
   137  	return &s3Error{
   138  		code:       "MissingHeaders",
   139  		message:    "Some headers in the query are missing from the file. Check the file and try again.",
   140  		statusCode: 400,
   141  		cause:      err,
   142  	}
   143  }
   144  
   145  func errUnrecognizedFormatException(err error) *s3Error {
   146  	return &s3Error{
   147  		code:       "UnrecognizedFormatException",
   148  		message:    "Encountered an invalid record type.",
   149  		statusCode: 400,
   150  		cause:      err,
   151  	}
   152  }
   153  
   154  // ////////////////////////////////////////////////////////////////////////////////////
   155  //
   156  //	SQL parsing errors.
   157  //
   158  // ////////////////////////////////////////////////////////////////////////////////////
   159  func errLexerInvalidChar(err error) *s3Error {
   160  	return &s3Error{
   161  		code:       "LexerInvalidChar",
   162  		message:    "The SQL expression contains an invalid character.",
   163  		statusCode: 400,
   164  		cause:      err,
   165  	}
   166  }
   167  
   168  func errLexerInvalidOperator(err error) *s3Error {
   169  	return &s3Error{
   170  		code:       "LexerInvalidOperator",
   171  		message:    "The SQL expression contains an invalid literal.",
   172  		statusCode: 400,
   173  		cause:      err,
   174  	}
   175  }
   176  
   177  func errLexerInvalidLiteral(err error) *s3Error {
   178  	return &s3Error{
   179  		code:       "LexerInvalidLiteral",
   180  		message:    "The SQL expression contains an invalid operator.",
   181  		statusCode: 400,
   182  		cause:      err,
   183  	}
   184  }
   185  
   186  func errLexerInvalidIONLiteral(err error) *s3Error {
   187  	return &s3Error{
   188  		code:       "LexerInvalidIONLiteral",
   189  		message:    "The SQL expression contains an invalid operator.",
   190  		statusCode: 400,
   191  		cause:      err,
   192  	}
   193  }
   194  
   195  func errParseExpectedDatePart(err error) *s3Error {
   196  	return &s3Error{
   197  		code:       "ParseExpectedDatePart",
   198  		message:    "Did not find the expected date part in the SQL expression.",
   199  		statusCode: 400,
   200  		cause:      err,
   201  	}
   202  }
   203  
   204  func errParseExpectedKeyword(err error) *s3Error {
   205  	return &s3Error{
   206  		code:       "ParseExpectedKeyword",
   207  		message:    "Did not find the expected keyword in the SQL expression.",
   208  		statusCode: 400,
   209  		cause:      err,
   210  	}
   211  }
   212  
   213  func errParseExpectedTokenType(err error) *s3Error {
   214  	return &s3Error{
   215  		code:       "ParseExpectedTokenType",
   216  		message:    "Did not find the expected token in the SQL expression.",
   217  		statusCode: 400,
   218  		cause:      err,
   219  	}
   220  }
   221  
   222  func errParseExpected2TokenTypes(err error) *s3Error {
   223  	return &s3Error{
   224  		code:       "ParseExpected2TokenTypes",
   225  		message:    "Did not find the expected token in the SQL expression.",
   226  		statusCode: 400,
   227  		cause:      err,
   228  	}
   229  }
   230  
   231  func errParseExpectedNumber(err error) *s3Error {
   232  	return &s3Error{
   233  		code:       "ParseExpectedNumber",
   234  		message:    "Did not find the expected number in the SQL expression.",
   235  		statusCode: 400,
   236  		cause:      err,
   237  	}
   238  }
   239  
   240  func errParseExpectedRightParenBuiltinFunctionCall(err error) *s3Error {
   241  	return &s3Error{
   242  		code:       "ParseExpectedRightParenBuiltinFunctionCall",
   243  		message:    "Did not find the expected right parenthesis character in the SQL expression.",
   244  		statusCode: 400,
   245  		cause:      err,
   246  	}
   247  }
   248  
   249  func errParseExpectedTypeName(err error) *s3Error {
   250  	return &s3Error{
   251  		code:       "ParseExpectedTypeName",
   252  		message:    "Did not find the expected type name in the SQL expression.",
   253  		statusCode: 400,
   254  		cause:      err,
   255  	}
   256  }
   257  
   258  func errParseExpectedWhenClause(err error) *s3Error {
   259  	return &s3Error{
   260  		code:       "ParseExpectedWhenClause",
   261  		message:    "Did not find the expected WHEN clause in the SQL expression. CASE is not supported.",
   262  		statusCode: 400,
   263  		cause:      err,
   264  	}
   265  }
   266  
   267  func errParseUnsupportedToken(err error) *s3Error {
   268  	return &s3Error{
   269  		code:       "ParseUnsupportedToken",
   270  		message:    "The SQL expression contains an unsupported token.",
   271  		statusCode: 400,
   272  		cause:      err,
   273  	}
   274  }
   275  
   276  func errParseUnsupportedLiteralsGroupBy(err error) *s3Error {
   277  	return &s3Error{
   278  		code:       "ParseUnsupportedLiteralsGroupBy",
   279  		message:    "The SQL expression contains an unsupported use of GROUP BY.",
   280  		statusCode: 400,
   281  		cause:      err,
   282  	}
   283  }
   284  
   285  func errParseExpectedMember(err error) *s3Error {
   286  	return &s3Error{
   287  		code:       "ParseExpectedMember",
   288  		message:    "The SQL expression contains an unsupported use of MEMBER.",
   289  		statusCode: 400,
   290  		cause:      err,
   291  	}
   292  }
   293  
   294  func errParseUnsupportedCase(err error) *s3Error {
   295  	return &s3Error{
   296  		code:       "ParseUnsupportedCase",
   297  		message:    "The SQL expression contains an unsupported use of CASE.",
   298  		statusCode: 400,
   299  		cause:      err,
   300  	}
   301  }
   302  
   303  func errParseUnsupportedCaseClause(err error) *s3Error {
   304  	return &s3Error{
   305  		code:       "ParseUnsupportedCaseClause",
   306  		message:    "The SQL expression contains an unsupported use of CASE.",
   307  		statusCode: 400,
   308  		cause:      err,
   309  	}
   310  }
   311  
   312  func errParseUnsupportedAlias(err error) *s3Error {
   313  	return &s3Error{
   314  		code:       "ParseUnsupportedAlias",
   315  		message:    "The SQL expression contains an unsupported use of ALIAS.",
   316  		statusCode: 400,
   317  		cause:      err,
   318  	}
   319  }
   320  
   321  func errParseInvalidPathComponent(err error) *s3Error {
   322  	return &s3Error{
   323  		code:       "ParseInvalidPathComponent",
   324  		message:    "The SQL expression contains an invalid path component.",
   325  		statusCode: 400,
   326  		cause:      err,
   327  	}
   328  }
   329  
   330  func errParseMissingIdentAfterAt(err error) *s3Error {
   331  	return &s3Error{
   332  		code:       "ParseMissingIdentAfterAt",
   333  		message:    "Did not find the expected identifier after the @ symbol in the SQL expression.",
   334  		statusCode: 400,
   335  		cause:      err,
   336  	}
   337  }
   338  
   339  func errParseUnexpectedOperator(err error) *s3Error {
   340  	return &s3Error{
   341  		code:       "ParseUnexpectedOperator",
   342  		message:    "The SQL expression contains an unexpected operator.",
   343  		statusCode: 400,
   344  		cause:      err,
   345  	}
   346  }
   347  
   348  func errParseUnexpectedTerm(err error) *s3Error {
   349  	return &s3Error{
   350  		code:       "ParseUnexpectedTerm",
   351  		message:    "The SQL expression contains an unexpected term.",
   352  		statusCode: 400,
   353  		cause:      err,
   354  	}
   355  }
   356  
   357  func errParseUnexpectedToken(err error) *s3Error {
   358  	return &s3Error{
   359  		code:       "ParseUnexpectedToken",
   360  		message:    "The SQL expression contains an unexpected token.",
   361  		statusCode: 400,
   362  		cause:      err,
   363  	}
   364  }
   365  
   366  func errParseUnExpectedKeyword(err error) *s3Error {
   367  	return &s3Error{
   368  		code:       "ParseUnExpectedKeyword",
   369  		message:    "The SQL expression contains an unexpected keyword.",
   370  		statusCode: 400,
   371  		cause:      err,
   372  	}
   373  }
   374  
   375  func errParseExpectedExpression(err error) *s3Error {
   376  	return &s3Error{
   377  		code:       "ParseExpectedExpression",
   378  		message:    "Did not find the expected SQL expression.",
   379  		statusCode: 400,
   380  		cause:      err,
   381  	}
   382  }
   383  
   384  func errParseExpectedLeftParenAfterCast(err error) *s3Error {
   385  	return &s3Error{
   386  		code:       "ParseExpectedLeftParenAfterCast",
   387  		message:    "Did not find the expected left parenthesis after CAST in the SQL expression.",
   388  		statusCode: 400,
   389  		cause:      err,
   390  	}
   391  }
   392  
   393  func errParseExpectedLeftParenValueConstructor(err error) *s3Error {
   394  	return &s3Error{
   395  		code:       "ParseExpectedLeftParenValueConstructor",
   396  		message:    "Did not find expected the left parenthesis in the SQL expression.",
   397  		statusCode: 400,
   398  		cause:      err,
   399  	}
   400  }
   401  
   402  func errParseExpectedLeftParenBuiltinFunctionCall(err error) *s3Error {
   403  	return &s3Error{
   404  		code:       "ParseExpectedLeftParenBuiltinFunctionCall",
   405  		message:    "Did not find the expected left parenthesis in the SQL expression.",
   406  		statusCode: 400,
   407  		cause:      err,
   408  	}
   409  }
   410  
   411  func errParseExpectedArgumentDelimiter(err error) *s3Error {
   412  	return &s3Error{
   413  		code:       "ParseExpectedArgumentDelimiter",
   414  		message:    "Did not find the expected argument delimiter in the SQL expression.",
   415  		statusCode: 400,
   416  		cause:      err,
   417  	}
   418  }
   419  
   420  func errParseCastArity(err error) *s3Error {
   421  	return &s3Error{
   422  		code:       "ParseCastArity",
   423  		message:    "The SQL expression CAST has incorrect arity.",
   424  		statusCode: 400,
   425  		cause:      err,
   426  	}
   427  }
   428  
   429  func errParseEmptySelect(err error) *s3Error {
   430  	return &s3Error{
   431  		code:       "ParseEmptySelect",
   432  		message:    "The SQL expression contains an empty SELECT.",
   433  		statusCode: 400,
   434  		cause:      err,
   435  	}
   436  }
   437  
   438  func errParseSelectMissingFrom(err error) *s3Error {
   439  	return &s3Error{
   440  		code:       "ParseSelectMissingFrom",
   441  		message:    "The SQL expression contains a missing FROM after SELECT list.",
   442  		statusCode: 400,
   443  		cause:      err,
   444  	}
   445  }
   446  
   447  func errParseExpectedIdentForGroupName(err error) *s3Error {
   448  	return &s3Error{
   449  		code:       "ParseExpectedIdentForGroupName",
   450  		message:    "GROUP is not supported in the SQL expression.",
   451  		statusCode: 400,
   452  		cause:      err,
   453  	}
   454  }
   455  
   456  func errParseExpectedIdentForAlias(err error) *s3Error {
   457  	return &s3Error{
   458  		code:       "ParseExpectedIdentForAlias",
   459  		message:    "Did not find the expected identifier for the alias in the SQL expression.",
   460  		statusCode: 400,
   461  		cause:      err,
   462  	}
   463  }
   464  
   465  func errParseUnsupportedCallWithStar(err error) *s3Error {
   466  	return &s3Error{
   467  		code:       "ParseUnsupportedCallWithStar",
   468  		message:    "Only COUNT with (*) as a parameter is supported in the SQL expression.",
   469  		statusCode: 400,
   470  		cause:      err,
   471  	}
   472  }
   473  
   474  func errParseMalformedJoin(err error) *s3Error {
   475  	return &s3Error{
   476  		code:       "ParseMalformedJoin",
   477  		message:    "JOIN is not supported in the SQL expression.",
   478  		statusCode: 400,
   479  		cause:      err,
   480  	}
   481  }
   482  
   483  func errParseExpectedIdentForAt(err error) *s3Error {
   484  	return &s3Error{
   485  		code:       "ParseExpectedIdentForAt",
   486  		message:    "Did not find the expected identifier for AT name in the SQL expression.",
   487  		statusCode: 400,
   488  		cause:      err,
   489  	}
   490  }
   491  
   492  func errParseCannotMixSqbAndWildcardInSelectList(err error) *s3Error {
   493  	return &s3Error{
   494  		code:       "ParseCannotMixSqbAndWildcardInSelectList",
   495  		message:    "Cannot mix [] and * in the same expression in a SELECT list in SQL expression.",
   496  		statusCode: 400,
   497  		cause:      err,
   498  	}
   499  }
   500  
   501  // ////////////////////////////////////////////////////////////////////////////////////
   502  //
   503  //	CAST() related errors.
   504  //
   505  // ////////////////////////////////////////////////////////////////////////////////////
   506  func errCastFailed(err error) *s3Error {
   507  	return &s3Error{
   508  		code:       "CastFailed",
   509  		message:    "Attempt to convert from one data type to another using CAST failed in the SQL expression.",
   510  		statusCode: 400,
   511  		cause:      err,
   512  	}
   513  }
   514  
   515  func errInvalidCast(err error) *s3Error {
   516  	return &s3Error{
   517  		code:       "InvalidCast",
   518  		message:    "Attempt to convert from one data type to another using CAST failed in the SQL expression.",
   519  		statusCode: 400,
   520  		cause:      err,
   521  	}
   522  }
   523  
   524  func errEvaluatorInvalidTimestampFormatPattern(err error) *s3Error {
   525  	return &s3Error{
   526  		code:       "EvaluatorInvalidTimestampFormatPattern",
   527  		message:    "Invalid time stamp format string in the SQL expression.",
   528  		statusCode: 400,
   529  		cause:      err,
   530  	}
   531  }
   532  
   533  func errEvaluatorInvalidTimestampFormatPatternAdditionalFieldsRequired(err error) *s3Error {
   534  	return &s3Error{
   535  		code:       "EvaluatorInvalidTimestampFormatPattern",
   536  		message:    "Time stamp format pattern requires additional fields in the SQL expression.",
   537  		statusCode: 400,
   538  		cause:      err,
   539  	}
   540  }
   541  
   542  func errEvaluatorInvalidTimestampFormatPatternSymbolForParsing(err error) *s3Error {
   543  	return &s3Error{
   544  		code:       "EvaluatorInvalidTimestampFormatPatternSymbolForParsing",
   545  		message:    "Time stamp format pattern contains a valid format symbol that cannot be applied to time stamp parsing in the SQL expression.",
   546  		statusCode: 400,
   547  		cause:      err,
   548  	}
   549  }
   550  
   551  func errEvaluatorTimestampFormatPatternDuplicateFields(err error) *s3Error {
   552  	return &s3Error{
   553  		code:       "EvaluatorTimestampFormatPatternDuplicateFields",
   554  		message:    "Time stamp format pattern contains multiple format specifiers representing the time stamp field in the SQL expression.",
   555  		statusCode: 400,
   556  		cause:      err,
   557  	}
   558  }
   559  
   560  func errEvaluatorTimestampFormatPatternHourClockAmPmMismatch(err error) *s3Error {
   561  	return &s3Error{
   562  		code:       "EvaluatorTimestampFormatPatternHourClockAmPmMismatch",
   563  		message:    "Time stamp format pattern contains a 12-hour hour of day format symbol but doesn't also contain an AM/PM field, or it contains a 24-hour hour of day format specifier and contains an AM/PM field in the SQL expression.",
   564  		statusCode: 400,
   565  		cause:      err,
   566  	}
   567  }
   568  
   569  func errEvaluatorUnterminatedTimestampFormatPatternToken(err error) *s3Error {
   570  	return &s3Error{
   571  		code:       "EvaluatorUnterminatedTimestampFormatPatternToken",
   572  		message:    "Time stamp format pattern contains unterminated token in the SQL expression.",
   573  		statusCode: 400,
   574  		cause:      err,
   575  	}
   576  }
   577  
   578  func errEvaluatorInvalidTimestampFormatPatternToken(err error) *s3Error {
   579  	return &s3Error{
   580  		code:       "EvaluatorInvalidTimestampFormatPatternToken",
   581  		message:    "Time stamp format pattern contains an invalid token in the SQL expression.",
   582  		statusCode: 400,
   583  		cause:      err,
   584  	}
   585  }
   586  
   587  func errEvaluatorInvalidTimestampFormatPatternSymbol(err error) *s3Error {
   588  	return &s3Error{
   589  		code:       "EvaluatorInvalidTimestampFormatPatternSymbol",
   590  		message:    "Time stamp format pattern contains an invalid symbol in the SQL expression.",
   591  		statusCode: 400,
   592  		cause:      err,
   593  	}
   594  }
   595  
   596  // //////////////////////////////////////////////////////////////////////
   597  //
   598  //	Generic S3 HTTP handler errors.
   599  //
   600  // //////////////////////////////////////////////////////////////////////
   601  func errBusy(err error) *s3Error {
   602  	return &s3Error{
   603  		code:       "Busy",
   604  		message:    "The service is unavailable. Please retry.",
   605  		statusCode: 503,
   606  		cause:      err,
   607  	}
   608  }
   609  
   610  func errUnauthorizedAccess(err error) *s3Error {
   611  	return &s3Error{
   612  		code:       "UnauthorizedAccess",
   613  		message:    "You are not authorized to perform this operation",
   614  		statusCode: 401,
   615  		cause:      err,
   616  	}
   617  }
   618  
   619  func errEmptyRequestBody(err error) *s3Error {
   620  	return &s3Error{
   621  		code:       "EmptyRequestBody",
   622  		message:    "Request body cannot be empty.",
   623  		statusCode: 400,
   624  		cause:      err,
   625  	}
   626  }
   627  
   628  func errUnsupportedRangeHeader(err error) *s3Error {
   629  	return &s3Error{
   630  		code:       "UnsupportedRangeHeader",
   631  		message:    "Range header is not supported for this operation.",
   632  		statusCode: 400,
   633  		cause:      err,
   634  	}
   635  }
   636  
   637  func errUnsupportedStorageClass(err error) *s3Error {
   638  	return &s3Error{
   639  		code:       "UnsupportedStorageClass",
   640  		message:    "Encountered an invalid storage class. Only STANDARD, STANDARD_IA, and ONEZONE_IA storage classes are supported.",
   641  		statusCode: 400,
   642  		cause:      err,
   643  	}
   644  }