Errors

This specification expects parsers of to emit certain errors when dealing with the semantics of the resource content (we do not address low-leve lexing/parsing errors). Each instance of an error reported to the client of the parser SHOULD include a message that denotes the details of the elements involved and SHOULD, if possible, the source location.

The following errors MUST be supported in a conforming DATALOG-TEXT processor. The naming convention used here for errors is commonly referred to as Screaming Snake Case where all characters are in upper case and all words are separated by underscores. A conforming DATALOG-TEXT processor SHOULD adapt this naming convention to the idiomatic form expected by a programmer in the implementation language.

Additional errors MAY be added, but where possible existing errors SHOULD BE used, distinguished by the message (See the non-normative § Error Type below) field on the error instance. Alternatively more detailed errors may be wrapped within one of the errors below using the caused_by field on the error instance.

Core Errors

ERR_UNSUPPORTED_DIALECT

The dialect specified in the vnd.datalog media type was not identified, or otherwise not supported by this parser.

ERR_UNSUPPORTED_SYNTAX

The parser found syntax that is not supported by the dialect specified in the vnd.datalog media type.

ERR_UNSUPPORTED_FEATURE

A feature identified by a feature pragma is not supported by this parser.

ERR_FEATURE_NOT_ENABLED

A required language feature during parsing was not enabled in the features pragma. The error ERR_FEATURE_NOT_ENABLED should be signaled instead if enabling the feature would result in such an error.

ERR_UNSUPPORTED_PROCESSING_INSTRUCTION

The processing instruction was not identified, or otherwise not supported by this parser.

ERR_UNSUPPORTED_PRAGMA

The pragma was not identified, or otherwise not supported by this parser.

ERR_INCONSISTENT_FACT_SCHEMA

Two facts are asserted but with different schema, or a fact is asserted with a different schema than it’s declared relation.

Given the following processing instruction .assert human(string)., the following fact is inconsistent human(24).

Or, if no relation declaration exists the first instance of a fact, say human("Alice")., is used to infer the relation schema and thus the following fact is inconsistent human(24).

ERR_PREDICATE_NOT_AN_EXTENSIONAL_RELATION

A predicate is used in a context that identifies an extensional relation, however the label was not in the extensional database.

ERR_PREDICATE_NOT_AN_INTENSIONAL_RELATION

A predicate is used in a context that identifies an intensional relation, however the label was not in the intensional database.

ERR_RELATION_ALREADY_EXISTS

An attempt was made to declare a relation where one already exists.

ERR_EXTENSIONAL_RELATION_IN_RULE_HEAD

A previously identified extensional relation, either with the assert processing instruction or inferred from a fact, appears in the head of a rule.

ERR_HEAD_VARIABLE_NOT_IN_POSITIVE_RELATIONAL_LITERAL

A variable that is used within the head of a rule does not also appear in a positive relational literal. For example, the following is invalid: a(X) :- b(Y).

ERR_INVALID_NUMBER_OF_ATOMS_IN_HEAD

A $\small\text{Datalog}$ program requires one, and only one, atom in a rule’s head. Also see § With Constraints and § With Disjunction for modifications to this error condition.

ERR_INVALID_TYPE

A value was provided which did not match the expected type.

ERR_MISSING_VALUE

An expected value was not found.

ERR_INVALID_VALUE_FOR_TYPE

A value was provided that is an invalid representation of the expected type.

ERR_INVALID_RELATION

A relation cannot be constructed, either from the values provided to an assert or infer processing instruction or during rule evaluation.

WARN_DUPLICATE

Signaled on any duplicate declaration, processing instruction, fact, rule, or query.

WARN_RULE_IS_ALWAYS_TRUE

This rule will always evaluate to true. See also WARN_ARITHMETIC_LITERAL_IS_ALWAYS_TRUE.

WARN_RULE_IS_ALWAYS_FALSE

This rule will always evaluate to false. See also WARN_ARITHMETIC_LITERAL_IS_ALWAYS_FALSE.

Resolver Errors

The following errors are introduced for use by the resolver subcomponent of the DATALOG-TEXT processor.

ERR_UNSUPPORTED_MEDIA_TYPE

A media type present in an input or output``input or output processing instruction is not supported by this processor.

ERR_INVALID_URI

The URI present in an input or output processing instruction could not be parsed, and constructed as a valid absolute URI.

ERR_INPUT_RESOURCE_DOES_NOT_EXIST

Having constructed a valid absolute URI no resource was found. For example in an HTTP response this would be the error 404 NOT FOUND.

Opening a file-system resource would be one of the errors ENODEV, ENOENT, or ENOTDIR1.

ERR_INVALID_INPUT_RESOURCE

The resource was retrieved, but it was not possible to parse it according to its expected media type.

ERR_OUTPUT_RESOURCE_NOT_WRITEABLE

An output processing instruction identified a resource but the relation could not be written to that resource.

ERR_IO_INSTRUCTION_PARAMETER

A parameter specified for an input or output processing instruction does not match the expectations of the media type, or does not match the relation’s schema.

ERR_IO_SYSTEM_FAILURE

The underlying input output system reported a failure. For file URIs this is typically file system errors, for http this would be HTTP, RFC2616 § 10. Status Code Definitions, or network errors.

Evaluator Errors

This section is non-normative.

The following errors are introduced for use by the evaluator subcomponent of the DATALOG-TEXT processor. This section is non-normative because this specification does not address any behavior required of the evaluator. It is included here because in some cases a parser may choose to perform more detailed semantic evaluation of rules which would result in these errors.

ERR_NOT_EVALUABLE

The parsed and resolved resource cannot be evaluated, this is generally a catch-all error when the parsed resource semantics are unclear or contradictory.

ERR_INCOMPATIBLE_RELATION_SCHEMA

This error occurs when evaluating rules where the required operation two or more relations (union, intersection, cartesian product, join, …) cannot be performed as the relations have incompatible schema.

With Negation

ERR_NEGATIVE_VARIABLE_NOT_IN_POSITIVE_RELATIONAL_LITERAL

A variable that is used within a negated literal does not also appear in a positive relational literal. For example, the following is invalid: a(X) :- b(Y), NOT b(X).

With Arithmetic Literals

ERR_ARITHMETIC_VARIABLE_NOT_IN_POSITIVE_RELATIONAL_LITERAL

A variable that is used within an arithmetic literal does not also appear in a positive relational literal. For example, the following is invalid: a(X) :- b(Y), X < Y.

ERR_INVALID_OPERATOR_FOR_TYPE

The operator is not specified for the type of the current entity.

ERR_INCOMPATIBLE_TYPES_FOR_OPERATOR

The left-hand and right-hand sides of the literal are of different types and the operator cannot be used with the combination of types.

WARN_ARITHMETIC_LITERAL_IS_ALWAYS_TRUE

Evaluation of this literal will always return true. For example 1 = 1.

WARN_ARITHMETIC_LITERAL_IS_ALWAYS_FALSE

Evaluation of this literal will always return false. For example 1 = 2

With Constraints

The error ERR_INVALID_NUMBER_OF_ATOMS_IN_HEAD is relaxed in $\small\text{Datalog}^{\Leftarrow}$ to allow zero atoms in a rule’s head.

With Disjunction

The error ERR_INVALID_NUMBER_OF_ATOMS_IN_HEAD is relaxed in $\small\text{Datalog}^{\lor}$ to allow more than one atom in a rule’s head.

With Functional Dependencies/IO

.assert employee(ein: integer, name: string, ssn: string, active: bool).
.fd employee: ein --> ssn.
.fd employee: ein --> 2, 4. 
ERR_INVALID_ATTRIBUTE_INDEX

The integer index in the functional dependency specification is not a valid attribute index in the relation.

For example, in .fd employee: employee_id --> ssn. the attribute label employee_id is invalid.

This error is also used to denote invalid columns specified in input or output processing instructions.

ERR_INVALID_ATTRIBUTE_LABEL

The predicate in the functional dependency specification is not a valid attribute label in the relation.

For example, in .fd employee: ein --> 2, 24. the index 24 is invalid.

This error is also used to denote invalid columns specified in input or output processing instructions.

The error ERR_PREDICATE_NOT_AN_EXTENSIONAL_RELATION is raised if the relation predicate in the processing instruction has not been asserted as an extensional relation.

Error Type

This section is non-normative.

This specification assumes the presence of a type that allows the instance of a signaled error to carry information regarding the location of the error and any other relevant context. The following is a non-normative structure that may be referenced by this specification.

structure Error {
    kind: ErrorKind,
    caused_by: Option<Error>,
    source_line: Option<integer>,
    source_column: Option<integer>,
    message: string,
}
  • kind – the error identifier.
  • caused_by – an optional inner value allowing error instances to be nested.
  • source_line – where possible the parser should identify the 1-based line number where the error occurred.
  • source_column – where possible the parser should identify the 1-based column number where the error occurred.
  • message – a string providing as much information as possible regarding this error instance including any labels associated with values in error.

The above structure required a type ErrorKind, this is the enumeration of all the error identifiers from the section above.

enumeration ErrorKind {
    ERR_UNSUPPORTED_DIALECT,
    …
}

 


1

From The Open Group man page for the open() function.