classConstant
final class Constant
implements Scalar, OutputNaming, IntegerValued
uses Snapshot
@visibility public.A numeric, string or bit-string constant used as an expression.
Rule: PG-CONSTANT-001. Facts: an integer constant is integer when it fits 32 bits; a numeric constant written as an integer is bigint when it fits 64 bits and numeric otherwise, as make_const reads the text of a T_Float node first as int8 and then as numeric; a constant with a decimal point or exponent is numeric; a string constant is of the pseudo-type unknown until its context resolves it; a bit-string constant is bit. A constant is never NULL and gives a result column no name. Source: https://www.postgresql.org/docs/17/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS, https://www.postgresql.org/docs/17/typeconv-overview.html, make_const in src/backend/parser/parse_node.c of PostgreSQL 17. Status: Implemented.
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT 3000000000');
$query->field(0)->type->descriptor->name() // => 'bigint'Properties§
public IntegerConstant|NumericConstant|StringConstant|BitStringConstant $valueMethods§
public function __construct(public IntegerConstant|NumericConstant|StringConstant|BitStringConstant $value)Parameters
$value | IntegerConstant|NumericConstant|StringConstant|BitStringConstant | The exact value |
public function builtin(): BuiltinAnswers the catalog type of the constant.
Returns
Test cases 2
Called from 1
Calls 8
- class-const Builtin::Int4() line 56
- method-call Numerals::integer() line 59
- new Numerals line 59
- method-call Numerals::within() line 61
- class-const Builtin::Int8() line 61
- class-const Builtin::Numeric() line 61
- class-const Builtin::Unknown() line 64
- class-const Builtin::Bit() line 64
public function integerValue(): ?stringAnswers the integer an integer constant, or a string constant spelling one, denotes.
Returns
?stringTest cases 1
Calls 3
- function-call
preg_matchline 75 - method-call Numerals::canonical() line 78
- new Numerals line 78
public function outputName(): ?Namepublic function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the type of the constant; a constant is never NULL.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 4
- new ScalarFact line 96
- new Known line 96
- method-call Constant::builtin() line 96
- class-const Nullability::NotNull() line 96
public function render(Output $out): voidTest cases 237§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
ConstantTest::testBuiltinFollowsTheSizeOfAnIntegercallsConstantTest::testBuiltinOfTheOtherConstantscallsConstantTest::testDeriveScalarIsTheCatalogTypeAndNeverNullcallsConstantTest::testIntegerValueReadsIntegersAndStringsThatSpellOnecallsConstantTest::testOutputNameIsNonecallsConstantTest::testRenderWritesTheValuecalls
Other tests reaching this symbol 231
ExpressionsTest::testNegationBuildsAPrefixMinuscallsLiteralsTest::testConstantLowersEveryPlainConstantcallsClauseRuleTest::testGroupingTermsFlattensAnImplicitRowInParenthesescallsClauseRuleTest::testGroupingTermsKeepsAnExplicitRowcallsClauseRuleTest::testPositionedWrapsIntegerConstantscallsLimitRuleTest::testOffsetLowersTheStartcallsLimitRuleTest::testOffsetValueLowersTheExpressioncallsLimitRuleTest::testRowsOffsetLowersTheStandardSpellingcallsQueriesTest::testSortClauseKeepsIntegerConstantscallsFunctionRuleTest::testReturnLowersTheExpressioncallsDesignationsTest::testNumericLowersADecimalSpellingWithItsModifierscallsArrayTypingTest::testItemsGivesTextForStringscallsCaseTypingTest::testDeriveReportsANonBooleanConditioncallsPrefixTypingTest::testPrefixFoldsANegativeConstantcallsCallChecksTest::testArgumentsReportsNamingMistakescallsCallChecksTest::testMisuseReportsEveryClauseAPlainFunctionRejectscallsCallTypingTest::testCallDependsWhenAnotherSchemaIsSearchedFirstcallsCallTypingTest::testCallLeavesNamedArgumentsToTheRoutinecallsCallTypingTest::testCallTypesAnExactCatalogMatchcallsJsonChecksTest::testInputReportsAnEncodingOnANonByteaValuecallsJsonChecksTest::testQueryReportsFormatInReturningAndQuotesWithWrappercallsWindowChecksTest::testSpecificationLeavesARefinedWindowToTheWindowClausecallsWindowChecksTest::testSpecificationReportsARangeOffsetWithoutASingleOrderingcallsXmlChecksTest::testAttributesReportsUnnamedValuesAndRepeatedNamescallsXmlChecksTest::testElementsReportsUnnamedValuescallsCarriersTest::testCarryAddsAnOccurrenceNoNameReachescallsCarriersTest::testCoreUnwrapsParenthesesAndClausescallsCarriersTest::testTakeAnswersTheCarriersOfAQuerycallsCarrierTest::testDeriveRelationAnswersARowWithoutColumnscallsCarrierTest::testRenderWritesNothingcallsClosedListTest::testOfAcceptsItemsOfTheClassescallsCommonTableFactsTest::testMarkIsTheCommonTypeOfTheValuescallsCommonTableFactsTest::testMemberReportsASearchColumnTheTableLackscallsCommonTableFactsTest::testOrderDerivesReferencedTablesFirstcallsCommonTableFactsTest::testRecursiveFormReportsAQueryWithoutUnioncallsCommonTableFactsTest::testShapeAddsTheSearchAndCycleColumnscallsSetOperationFactsTest::testReboundBindsTheRecursiveTablecallsFetchCountsTest::testAdmitsAPrimaryExpressionOrASignedConstantcallsOrderingTest::testSameComparesTheExpressionscallsPositionsTest::testMinusTellsThePlainMinusSigncallsPositionsTest::testMisusedTellsANonIntegerConstantcallsTargetNamesTest::testNameFallsBackToQuestionColumncallsTableShapesTest::testInputReportsASampleOfACommonTablecallsModifiersTest::testApplyReadsIntegerConstantscallsBinaryOperationTest::testAcceptsAGroupedOperandcallsBinaryOperationTest::testDeriveScalarDependsOnAnOperatorOutsideTheCatalogcallsBinaryOperationTest::testDeriveScalarIsBooleanForCatalogComparisonscallsBinaryOperationTest::testDeriveScalarIsNullableWhenAnOperandIsNullcallsBinaryOperationTest::testDeriveScalarPromotesAnIntegerAndANumericcallsBinaryOperationTest::testOutputNameIsNonecallsBinaryOperationTest::testRejectsALeftOperandThatBindsWeakercallsBinaryOperationTest::testRejectsAQualifiedOperatorWithoutTheOperatorSyntaxcallsBinaryOperationTest::testRejectsARightOperandOfTheSameLevelcallsBinaryOperationTest::testRenderWritesTheOperatorBetweenTheOperandscallsCastTest::testRejectsAnOperandThatBindsWeakercallsCastTest::testRenderWritesBothSpellingscallsCollationTest::testDeriveScalarKeepsAStringTypecallsCollationTest::testDeriveScalarReportsATypeWithoutCollationscallsCollationTest::testRenderWritesTheCollationNamecallsArrayConstructorTest::testDeriveScalarIsAnArrayOfTheCommonTypecallsArrayConstructorTest::testDeriveScalarReportsValuesWithoutACommonTypecallsCaseExpressionTest::testDeriveScalarUnifiesTheResultscallsRowConstructorTest::testDeriveScalarIsARecordOfTheFieldscallsGroupingFunctionTest::testRenderWritesTheArgumentscallsIndirectionTest::testDeriveScalarSelectsAFieldOfARowcallsIndirectionTest::testRenderWritesTheBaseAndTheStepscallsAtLocalTest::testDeriveScalarTurnsATimestampWithZoneIntoATimestampcallsAtTimeZoneTest::testDeriveScalarTurnsAnUnknownConstantIntoATimestampcallsBetweenTest::testDeriveScalarIsBooleancallsBooleanOperationTest::testDeriveScalarReportsANonBooleanOperandcallsDistinctTestTest::testDeriveScalarIsNeverNullcallsNegationTest::testDeriveScalarIsBooleancallsPatternMatchTest::testDeriveScalarIsBooleanForStringscallsUnaryOperationTest::testDeriveScalarKeepsTheTypeOfANegatedNumbercallsUnaryOperationTest::testDeriveScalarTypesANegativeConstantByItsValuecallsUnaryOperationTest::testRejectsAnOperandThatBindsWeakercallsUnaryOperationTest::testRenderWritesTheOperatorFirstcallsBooleanTestTest::testDeriveScalarReportsANonBooleanOperandcallsDocumentTestTest::testDeriveScalarReportsANonXmlOperandcallsJsonTestTest::testDeriveScalarIsBooleanForAStringcallsJsonTestTest::testDeriveScalarReportsAnIntegercallsNormalizationTestTest::testDeriveScalarIsBooleanForTextcallsSliceTest::testDeriveClauseDerivesTheWrittenBoundscallsSliceTest::testRenderWritesTheBoundscallsSubscriptTest::testDeriveClauseDerivesTheIndexcallsSubscriptTest::testRenderWritesBracketscallsInListTest::testDeriveScalarIsNullableWithANullItemcallsInSubqueryTest::testDeriveScalarComparesWithTheColumncallsQuantifiedArrayTest::testDeriveScalarComparesWithTheElementTypecallsQuantifiedArrayTest::testDeriveScalarReportsANonArraycallsQuantifiedSubqueryTest::testDeriveScalarComparesWithTheColumncallsArgumentTest::testValueIsTheExpressionPassedcallsCoalesceTest::testDeriveScalarIsNotNullWhenAValueIsNotNullcallsCoalesceTest::testRenderWritesTheValuescallsMinMaxTest::testDeriveScalarIsTheCommonTypecallsMinMaxTest::testRenderWritesTheKeywordcallsNullIfTest::testDeriveScalarPromotesAStringFirstOperandcallsNullIfTest::testDeriveScalarTakesTheTypeOfTheFirstOperandcallsNullIfTest::testRenderWritesBothOperandscallsFrameBoundTest::testDeriveClauseDerivesTheOffsetcallsFrameBoundTest::testRenderWritesTheOffsetBeforeTheKeywordcallsFunctionCallTest::testDeriveScalarDependsOnAnUndeclaredRoutinecallsFunctionCallTest::testDeriveScalarDerivesTheClausescallsFunctionCallTest::testDeriveScalarTypesACatalogFunctioncallsFunctionCallTest::testRejectsAnOrderingWithoutArgumentscallsFunctionCallTest::testRejectsWithinGroupWithDistinctcallsFunctionCallTest::testRenderQuotesAnUnqualifiedCubeOrRollupcallsFunctionCallTest::testRenderWritesDistinctVariadicAndAnInnerOrderingcallsFunctionCallTest::testRenderWritesEveryPartInOrdercallsJsonArrayAggregateTest::testDeriveScalarDerivesTheOrderingcallsJsonArrayAggregateTest::testRenderWritesTheOrderingAndTheWindowcallsJsonArrayConstructorTest::testDeriveScalarIsJsoncallsJsonArrayConstructorTest::testRenderWritesTheNullClausecallsJsonObjectAggregateTest::testDeriveScalarDerivesTheFilterAndTheWindowcallsJsonObjectAggregateTest::testOutputNameIsJsonObjectaggcallsJsonObjectAggregateTest::testRenderWritesTheClausesFilterAndWindowcallsJsonObjectConstructorTest::testDeriveScalarIsJsonOrTheReturningTypecallsJsonObjectConstructorTest::testRenderWritesTheClausescallsJsonParseTest::testRenderWritesTheUniquenesscallsJsonScalarTest::testDeriveScalarFollowsTheValuecallsJsonScalarTest::testRenderWritesTheValuecallsJsonSerializeTest::testDeriveScalarIsTextWithoutReturningcallsJsonSerializeTest::testRenderWritesTheReturningClausecallsJsonPairTest::testDeriveClauseDerivesTheKeyAndTheValuecallsJsonPairTest::testRejectsAKeyBeforeValueThatIsNotPrimarycallsJsonPairTest::testRenderWritesBothSpellingscallsJsonValueExpressionTest::testDeriveClauseDerivesTheValuecallsJsonValueExpressionTest::testDeriveValueAnswersTheFactsOfTheValuecallsJsonValueExpressionTest::testDeriveValueReportsAnEncodingOnTextcallsJsonValueExpressionTest::testRenderWritesTheFormatcallsJsonArgumentTest::testDeriveClauseDerivesTheValuecallsJsonArgumentTest::testRenderWritesTheNamecallsJsonBehaviorClauseTest::testDeriveClauseDerivesBothDefaultscallsJsonBehaviorTest::testDeriveClauseDerivesTheDefaultcallsJsonQueryFunctionTest::testDeriveScalarIsTheReturningTypecallsJsonQueryFunctionTest::testDeriveScalarReportsAnInvalidBehaviorcallsJsonQueryFunctionTest::testOutputNameIsTheFunctioncallsJsonQueryFunctionTest::testRejectsAPathThatWouldTakeTheWrappercallsJsonQueryFunctionTest::testRejectsAWrapperOutsideJsonQuerycallsJsonQueryFunctionTest::testRejectsReturningOnJsonExistscallsJsonQueryFunctionTest::testRenderWritesEveryClauseInOrdercallsNamedArgumentTest::testDeriveClauseDerivesTheValuecallsNamedArgumentTest::testRenderWritesTheArrowSpellingcallsNamedArgumentTest::testRenderWritesTheAssignmentSpellingAndQuotesAColumnNameKeywordcallsNamedArgumentTest::testValueAnswersTheValuePassedcallsPositionalArgumentTest::testDeriveClauseDerivesTheValuecallsPositionalArgumentTest::testRenderWritesTheValuecallsPositionalArgumentTest::testValueAnswersTheValuePassedcallsCollationForTest::testDeriveScalarIsNullableTextcallsCollationForTest::testRenderWritesTheKeywordscallsKeywordCallTest::testDeriveScalarLeavesNamedArgumentsToTheRoutinecallsKeywordCallTest::testDeriveScalarSearchesThePathForSubstringcallsKeywordCallTest::testRenderWritesTheKeywordAndTheArgumentscallsNormalizeTest::testDeriveScalarIsTextcallsNormalizeTest::testRenderWritesTheFormcallsTreatTest::testDeriveScalarDependsOnTheConversionFunctioncallsTreatTest::testRenderWritesTheValueAndTheTypecallsExtractTest::testDeriveScalarDependsForAnAmbiguousSourcecallsOverlayTest::testDeriveScalarIsTheStringTypecallsOverlayTest::testRenderWritesTheKeywordscallsPositionTest::testDeriveScalarIsIntegercallsPositionTest::testRenderWritesTheSubstringFirstcallsSimilarSubstringTest::testDeriveScalarIsTextcallsSimilarSubstringTest::testRenderWritesTheKeywordscallsSubstringTest::testDeriveScalarTypesTheCountOnlyFormAsAnIntegerCallcallsSubstringTest::testOutputNameIsSubstringcallsSubstringTest::testRejectsCountFirstWithoutBothcallsSubstringTest::testRenderKeepsTheOrderWrittencallsTrimTest::testDeriveScalarDependsForTooManyStringscallsTrimTest::testDeriveScalarPassesTheCharactersLastcallsTrimTest::testRenderLeavesTheDefaultSideUnwrittencallsWindowFrameTest::testDeriveClauseDerivesTheOffsetsOfBothBoundscallsWindowFrameTest::testRejectsAStartAfterTheCurrentRowWithoutAnEndcallsWindowFrameTest::testRenderWritesBetweenForTwoBoundscallsWindowSpecificationTest::testDeriveClauseDerivesPartitionOrderAndFramecallsWindowSpecificationTest::testRenderWritesTheSpecificationInParenthesescallsXmlAttributeTest::testDeriveClauseDerivesTheValuecallsXmlAttributeTest::testRenderWritesTheNamecallsXmlElementTest::testDeriveScalarReportsAnUnnamedAttributecallsXmlElementTest::testRenderWritesAttributesAndContentcallsXmlExistsTest::testDeriveScalarIsBooleancallsXmlExistsTest::testRejectsAPathThatIsNotPrimarycallsXmlExistsTest::testRenderWritesThePassingClausecallsXmlForestTest::testDeriveScalarReportsAnUnnamedValuecallsXmlForestTest::testRenderWritesTheValuescallsXmlParseTest::testRenderWritesTheWhitespaceOptioncallsXmlPassingTest::testDeriveClauseDerivesTheDocumentcallsXmlPassingTest::testRejectsADocumentThatIsNotPrimarycallsXmlPassingTest::testRenderWritesPassingcallsXmlProcessingInstructionTest::testRenderWritesTheContentcallsXmlRootTest::testDeriveScalarFollowsTheValuecallsXmlRootTest::testRenderWritesNoValueAndStandalonecallsXmlSerializeTest::testDeriveScalarIsTheCharacterTypecallsXmlSerializeTest::testDeriveScalarReportsATypeThatIsNotACharacterTypecallsXmlSerializeTest::testRenderWritesTheIndentationcallsIntegerValuedTest::testIntegerValueIsOfferedByAConstantcallsTypedLiteralTest::testDeriveScalarDerivesTheModifiersAndTheTypecallsTypedLiteralTest::testDeriveScalarReportsInvalidModifierscallsAttributeTest::testDeriveClauseDerivesTheValuecallsChoiceArgumentTest::testDeriveClauseDerivesTheModifiersOfATypeNamecallsNameArgumentTest::testDeriveClauseDerivesTheModifiersOfATypeNamecallsTextArgumentTest::testDeriveClauseDerivesTheModifiersOfATypeNamecallsTypeArgumentTest::testDeriveClauseDerivesTheModifierscallsDefinitionTest::testDeriveClauseDerivesTheModifiersOfATypeValuecallsSelectOptionsTest::testLocksTellsLockingAndReadOnlycallsExpressionTargetTest::testNameIsTheAliasOrTheNameTheExpressionGivescallsSortItemTest::testDeriveClauseDerivesTheSortKeycallsSortItemTest::testRejectsADirectionNextToAnOperatorcallsSortItemTest::testRenderWritesDirectionAndNullscallsSortItemTest::testRenderWritesTheOrderingOperatorcallsCommonTableExpressionTest::testRecursiveColumnsAreTheWrittenColumnscallsCommonTableExpressionTest::testRecursiveQueryIsTheStatementcallsCommonTableExpressionTest::testRenderWritesTheNameColumnsAndStatementcallsCycleClauseTest::testRenderWritesTheMarkValuescallsRecursiveDefinitionTest::testRecursiveColumnsAreTheWrittenNamescallsRecursiveDefinitionTest::testRecursiveQueryIsTheComputingQuerycallsWithClauseTest::testDeriveCommonTablesBindsTheTablescallsWithClauseTest::testRenderWritesRecursivecallsFunctionParameterTest::testDeriveClauseDerivesTheDefaultValuecallsFunctionParameterTest::testRenderWritesTheNameBeforeTheModeWhenWrittenSocallsRoutineSignatureTest::testRejectsADefaultValuecallsBitDesignationTest::testDeriveClauseDerivesTheModifierscallsBitDesignationTest::testRenderWritesVaryingAndTheLengthcallsDecimalDesignationTest::testDeriveClauseDerivesTheModifierscallsDecimalDesignationTest::testRenderWritesTheKeywordAndTheModifierscallsDecimalDesignationTest::testTypeFactAppliesPrecisionAndScalecallsNamedDesignationTest::testDeriveClauseDerivesTheModifierscallsNamedDesignationTest::testRenderQuotesANameTheGrammarReadsAsAKeywordTypecallsNamedDesignationTest::testTypeFactLooksTheNameUpAndAppliesTheModifierscallsTypedColumnTest::testDeriveClauseDerivesTheModifiersOfTheTypecallsTypeNameTest::testDeriveClauseDerivesTheModifierscalls
Relations§
Instantiated in 7
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::constant() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:186
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::constant() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:187
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::constant() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:188
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::constant() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:189
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::constant() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:190
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::fetchValue() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:199
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\LimitRule::fetchValue() packages/sql-semantics-postgres/src/Lowering/Query/LimitRule.php:200
Type checks 6
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::prefix() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:50
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\FetchCounts::admits() packages/sql-semantics-postgres/src/Rules/Query/FetchCounts.php:37
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Positions::value() packages/sql-semantics-postgres/src/Rules/Query/Positions.php:43
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\Positions::misused() packages/sql-semantics-postgres/src/Rules/Query/Positions.php:63
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Query\UnknownOutputs::raw() packages/sql-semantics-postgres/src/Rules/Query/UnknownOutputs.php:39
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Resolution\TableFunctionShapes::json() packages/sql-semantics-postgres/src/Rules/Resolution/TableFunctionShapes.php:127