Skip to content

Latest commit

 

History

History
1266 lines (808 loc) · 50.5 KB

File metadata and controls

1266 lines (808 loc) · 50.5 KB

src/minisql/sql/expressions.ml

Home · Files

Provides minisql sql expressions facilities for this project.

Package: minisql.sql.expressions

Reachable from entry: yes

Imports

Declarations

absoluteValue

function absoluteValue(value)

Returns the absolute value while preserving full-width signed integer semantics.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

aggregate

function aggregate(name, argument, separator, distinct, typeInfo, countStar)

Implements aggregate for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
name dynamic Name of the affected item.
argument dynamic argument value consumed by this operation.
separator dynamic separator value consumed by this operation.
distinct dynamic distinct value consumed by this operation.
typeInfo dynamic typeInfo value consumed by this operation.
countStar dynamic countStar value consumed by this operation.

View source

asciiCase

function asciiCase(value, upper)

Applies ASCII case conversion while preserving every non-ASCII UTF-8 byte.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.
upper dynamic upper value consumed by this operation.

View source

betweenPredicate

function betweenPredicate(operand, lower, upper, negated)

Implements between predicate for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
operand dynamic operand value consumed by this operation.
lower dynamic lower value consumed by this operation.
upper dynamic upper value consumed by this operation.
negated dynamic negated value consumed by this operation.

View source

binary

function binary(operator, left, right, typeInfo)

Implements binary for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
operator dynamic operator value consumed by this operation.
left dynamic left value consumed by this operation.
right dynamic right value consumed by this operation.
typeInfo dynamic typeInfo value consumed by this operation.

View source

BINDING_ERROR

const BINDING_ERROR = 9020

Defines the binding error constant used by the minisql sql expressions module.

View source

BOUND_AGGREGATE

const BOUND_AGGREGATE = 6

Defines the bound aggregate constant used by the minisql sql expressions module.

View source

BOUND_BETWEEN

const BOUND_BETWEEN = 11

Defines the bound between constant used by the minisql sql expressions module.

View source

BOUND_BINARY

const BOUND_BINARY = 4

Defines the bound binary constant used by the minisql sql expressions module.

View source

BOUND_CASE

const BOUND_CASE = 7

Defines the bound case constant used by the minisql sql expressions module.

View source

BOUND_CAST

const BOUND_CAST = 8

Defines the bound cast constant used by the minisql sql expressions module.

View source

BOUND_COLUMN

const BOUND_COLUMN = 2

Defines the bound column constant used by the minisql sql expressions module.

View source

BOUND_IN

const BOUND_IN = 10

Defines the bound in constant used by the minisql sql expressions module.

View source

BOUND_IS_NULL

const BOUND_IS_NULL = 5

Defines the bound is null constant used by the minisql sql expressions module.

View source

BOUND_LITERAL

const BOUND_LITERAL = 1

Defines the bound literal constant used by the minisql sql expressions module.

View source

BOUND_SCALAR

const BOUND_SCALAR = 9

Defines the bound scalar constant used by the minisql sql expressions module.

View source

BOUND_SUBQUERY

const BOUND_SUBQUERY = 14

Defines the bound subquery constant used by the minisql sql expressions module.

View source

BOUND_TRUTH_TEST

const BOUND_TRUTH_TEST = 12

Defines the bound truth test constant used by the minisql sql expressions module.

View source

BOUND_UNARY

const BOUND_UNARY = 3

Defines the bound unary constant used by the minisql sql expressions module.

View source

BOUND_WINDOW

const BOUND_WINDOW = 13

Defines the bound window constant used by the minisql sql expressions module.

View source

bytesMatchAt

function bytesMatchAt(source, needle, offset)

Returns whether needle occurs in source at the supplied byte offset.

Parameter Type Default Description
source dynamic source value consumed by this operation.
needle dynamic needle value consumed by this operation.
offset dynamic Zero-based offset at which processing starts.

View source

caseBranch

function caseBranch(condition, result)

Implements case branch for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
condition dynamic condition value consumed by this operation.
result dynamic Result object populated or inspected by the operation.

View source

caseExpression

function caseExpression(branches, elseExpression, typeInfo)

Implements case expression for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
branches dynamic branches value consumed by this operation.
elseExpression dynamic elseExpression value consumed by this operation.
typeInfo dynamic typeInfo value consumed by this operation.

View source

castExpression

function castExpression(operand, targetType)

Casts expression using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
operand dynamic operand value consumed by this operation.
targetType dynamic targetType value consumed by this operation.

View source

checkPasses

function checkPasses(expression, context)

Checks passes using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
context dynamic Context that carries state for the operation.

View source

civilDateFromEpochDays

function civilDateFromEpochDays(days)

Converts days since 1970-01-01 to Gregorian year, month and day.

Parameter Type Default Description
days dynamic days value consumed by this operation.

View source

column

function column(index, typeInfo)

Implements column for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
index dynamic Zero-based index of the affected item.
typeInfo dynamic typeInfo value consumed by this operation.

View source

comparisonResult

function comparisonResult(left, right, operator)

Implements comparison result for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
left dynamic left value consumed by this operation.
right dynamic right value consumed by this operation.
operator dynamic operator value consumed by this operation.

View source

componentName

function componentName()

Performs the componentName operation for the minisql sql expressions module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

View source

containsAggregate

function containsAggregate(expression)

Returns whether the supplied value satisfies the aggregate condition. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.

View source

containsSubquery

function containsSubquery(expression)

Returns true when an expression tree contains a row-dependent nested SELECT.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.

View source

containsSubqueryList

function containsSubqueryList(items)

Returns true when at least one expression in a list contains a subquery.

Parameter Type Default Description
items dynamic Items consumed or updated by the operation.

View source

containsWindow

function containsWindow(expression)

Returns whether the supplied value satisfies the window condition. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.

View source

containsWindowList

function containsWindowList(items)

Returns whether the supplied value satisfies the window list condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
items dynamic Items consumed or updated by the operation.

View source

evaluate

function evaluate(expression, context)

Evaluates evaluate using the supplied inputs. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
context dynamic Context that carries state for the operation.

View source

evaluateBetween

function evaluateBetween(expression, context)

Evaluates between using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
context dynamic Context that carries state for the operation.

View source

evaluateCase

function evaluateCase(expression, context)

Evaluates case using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
context dynamic Context that carries state for the operation.

View source

evaluateIn

function evaluateIn(expression, context)

Evaluates in using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
context dynamic Context that carries state for the operation.

View source

evaluateScalar

function evaluateScalar(expression, context)

Evaluates scalar using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
context dynamic Context that carries state for the operation.

View source

evaluateScalarValues

function evaluateScalarValues(expression, arguments)

Evaluates a scalar after its arguments have already been evaluated. This entry point is also used by grouped expressions containing aggregates.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
arguments dynamic arguments value consumed by this operation.

View source

evaluateTruthTest

function evaluateTruthTest(expression, context)

Evaluates truth test using the supplied inputs. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
context dynamic Context that carries state for the operation.

View source

fail

function fail(code, operation, message)

Performs the fail operation for the minisql sql expressions module. Returns its result or propagates a structured error from validation or a dependency. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
code dynamic code value consumed by this operation.
operation dynamic operation value consumed by this operation.
message dynamic Human-readable message associated with the operation.

View source

inPredicate

function inPredicate(operand, candidates, negated)

Implements in predicate for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
operand dynamic operand value consumed by this operation.
candidates dynamic candidates value consumed by this operation.
negated dynamic negated value consumed by this operation.

View source

integerDivide

function integerDivide(left, right)

Computes exact floor division for native integers.

Parameter Type Default Description
left dynamic left value consumed by this operation.
right dynamic right value consumed by this operation.

View source

INVALID_ARGUMENT

const INVALID_ARGUMENT = 9001

Defines the invalid argument constant used by the minisql sql expressions module.

View source

isBaseBoundExpression

function isBaseBoundExpression(value)

Returns whether the supplied value satisfies the base bound expression condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundAggregate

function isBoundAggregate(value)

Returns whether the supplied value satisfies the bound aggregate condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundBetween

function isBoundBetween(value)

Returns whether the supplied value satisfies the bound between condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundCase

function isBoundCase(value)

Returns whether the supplied value satisfies the bound case condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundCast

function isBoundCast(value)

Returns whether the supplied value satisfies the bound cast condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundExpression

function isBoundExpression(value)

Returns whether the supplied value satisfies the bound expression condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundIn

function isBoundIn(value)

Returns whether the supplied value satisfies the bound in condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundLiteral

function isBoundLiteral(value)

Returns whether the supplied value satisfies the bound literal condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundScalar

function isBoundScalar(value)

Returns whether the supplied value satisfies the bound scalar condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundSubquery

function isBoundSubquery(value)

Returns whether a bound expression defers a nested SELECT to row evaluation.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundTruthTest

function isBoundTruthTest(value)

Returns whether the supplied value satisfies the bound truth test condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isBoundWindow

function isBoundWindow(value)

Returns whether the supplied value satisfies the bound window condition. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.

View source

isImplemented

function isImplemented()

Returns whether implemented satisfies the condition required by the minisql sql expressions module. Returns the computed value or operation status. Does not modify its inputs.

View source

isNull

function isNull(operand, negated)

Returns whether the supplied value satisfies the null condition. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Does not modify its inputs.

Parameter Type Default Description
operand dynamic operand value consumed by this operation.
negated dynamic negated value consumed by this operation.

View source

likeResult

function likeResult(left, right)

Implements like result for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
left dynamic left value consumed by this operation.
right dynamic right value consumed by this operation.

View source

literal

function literal(value, typeInfo)

Implements literal for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
value dynamic Value consumed or transformed by the operation.
typeInfo dynamic typeInfo value consumed by this operation.

View source

numericResult

function numericResult(left, right, operator, resultType)

Implements numeric result for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
left dynamic left value consumed by this operation.
right dynamic right value consumed by this operation.
operator dynamic operator value consumed by this operation.
resultType dynamic resultType value consumed by this operation.

View source

predicatePasses

function predicatePasses(expression, context)

Implements predicate passes for this module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
context dynamic Context that carries state for the operation.

View source

referencesColumnAtOrAfter

function referencesColumnAtOrAfter(expression, minimumIndex)

Implements references column at or after for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
expression dynamic expression value consumed by this operation.
minimumIndex dynamic Zero-based index of minimum.

View source

replaceText

function replaceText(sourceText, searchText, replacementText)

Replaces all non-overlapping UTF-8 byte sequences without changing unaffected bytes.

Parameter Type Default Description
sourceText dynamic sourceText value consumed by this operation.
searchText dynamic searchText value consumed by this operation.
replacementText dynamic replacementText value consumed by this operation.

View source

rowContext

function rowContext(rowValues)

Implements row context for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
rowValues dynamic rowValues value consumed by this operation.

View source

sameBinding

function sameBinding(left, right)

Implements same binding for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
left dynamic left value consumed by this operation.
right dynamic right value consumed by this operation.

View source

scalar

function scalar(name, arguments, typeInfo)

Implements scalar for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
name dynamic Name of the affected item.
arguments dynamic arguments value consumed by this operation.
typeInfo dynamic typeInfo value consumed by this operation.

View source

subquery

function subquery(subqueryKind, query, operand, negated, typeInfo)

Creates a deferred subquery binding after its shape and result type have been validated.

Parameter Type Default Description
subqueryKind dynamic subqueryKind value consumed by this operation.
query dynamic query value consumed by this operation.
operand dynamic operand value consumed by this operation.
negated dynamic negated value consumed by this operation.
typeInfo dynamic typeInfo value consumed by this operation.

View source

SUBQUERY_EXISTS

const SUBQUERY_EXISTS = 2

Defines the subquery exists constant used by the minisql sql expressions module.

View source

SUBQUERY_IN

const SUBQUERY_IN = 3

Defines the subquery in constant used by the minisql sql expressions module.

View source

SUBQUERY_SCALAR

const SUBQUERY_SCALAR = 1

Defines the subquery scalar constant used by the minisql sql expressions module.

View source

targetMilestone

function targetMilestone()

Performs the targetMilestone operation for the minisql sql expressions module. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

View source

truthTest

function truthTest(operand, expected, negated)

Implements truth test for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
operand dynamic operand value consumed by this operation.
expected dynamic expected value consumed by this operation.
negated dynamic negated value consumed by this operation.

View source

TYPE_MISMATCH

const TYPE_MISMATCH = 9017

Defines the type mismatch constant used by the minisql sql expressions module.

View source

unary

function unary(operator, operand, typeInfo)

Implements unary for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
operator dynamic operator value consumed by this operation.
operand dynamic operand value consumed by this operation.
typeInfo dynamic typeInfo value consumed by this operation.

View source

utf8ByteOffset

function utf8ByteOffset(raw, characterIndex)

Maps a zero-based Unicode character index to a UTF-8 byte offset.

Parameter Type Default Description
raw dynamic raw value consumed by this operation.
characterIndex dynamic Zero-based index of character.

View source

utf8CharacterCount

function utf8CharacterCount(raw)

Counts Unicode scalar starts in validated UTF-8 text.

Parameter Type Default Description
raw dynamic raw value consumed by this operation.

View source

window

function window(name, arguments, partitionBy, orderBy, descending, nullsFirst, nullsSpecified, typeInfo)

Implements window for this module. Requires arguments that satisfy the validation performed below. Returns the computed value or operation status. Any side effects are limited to the explicitly invoked dependencies.

Parameter Type Default Description
name dynamic Name of the affected item.
arguments dynamic arguments value consumed by this operation.
partitionBy dynamic partitionBy value consumed by this operation.
orderBy dynamic orderBy value consumed by this operation.
descending dynamic descending value consumed by this operation.
nullsFirst dynamic nullsFirst value consumed by this operation.
nullsSpecified dynamic nullsSpecified value consumed by this operation.
typeInfo dynamic typeInfo value consumed by this operation.

View source