MCPcopy Create free account
hub / github.com/documentdb/documentdb / WriteQuals

Function WriteQuals

pg_documentdb/src/explain/documentdb_explain.c:529–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527
528
529static void
530WriteQuals(pgbson_writer *writer, List *quals)
531{
532 CHECK_FOR_INTERRUPTS();
533 check_stack_depth();
534
535 ListCell *qualCell;
536 foreach(qualCell, quals)
537 {
538 Expr *qual = (Expr *) lfirst(qualCell);
539
540 if (IsA(qual, BoolExpr))
541 {
542 BoolExpr *boolExpr = (BoolExpr *) qual;
543 switch (boolExpr->boolop)
544 {
545 case AND_EXPR:
546 {
547 pgbson_array_writer andWriter;
548 PgbsonWriterStartArray(writer, "$and", -1, &andWriter);
549 WriteBoolExpr(&andWriter, boolExpr);
550 PgbsonWriterEndArray(writer, &andWriter);
551 break;
552 }
553
554 case OR_EXPR:
555 {
556 pgbson_array_writer orWriter;
557 PgbsonWriterStartArray(writer, "$or", -1, &orWriter);
558 WriteBoolExpr(&orWriter, boolExpr);
559 PgbsonWriterEndArray(writer, &orWriter);
560 break;
561 }
562
563 case NOT_EXPR:
564 {
565 pgbson_writer notWriter;
566 PgbsonWriterStartDocument(writer, "$not", -1, &notWriter);
567 WriterSingleQual(&notWriter, linitial(boolExpr->args));
568 PgbsonWriterEndDocument(writer, &notWriter);
569 break;
570 }
571
572 default:
573 ereport(ERROR, (errmsg("Unsupported boolean operator in qual: %d",
574 boolExpr->boolop)));
575 }
576 }
577 else
578 {
579 WriterSingleQual(writer, qual);
580 }
581 }
582}
583
584
585static void

Callers 3

WriteBoolExprFunction · 0.85
LogIndexScanDetailsFunction · 0.85
WritePlanStateFunction · 0.85

Calls 7

PgbsonWriterStartArrayFunction · 0.85
WriteBoolExprFunction · 0.85
PgbsonWriterEndArrayFunction · 0.85
WriterSingleQualFunction · 0.85
PgbsonWriterEndDocumentFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected