Skip to content

Latest commit

 

History

History
53 lines (43 loc) · 2.6 KB

File metadata and controls

53 lines (43 loc) · 2.6 KB

InitializeQueryCompletion

Location

src/backend/tcop/cmdtag.c:40-46

Overview

Initializes a QueryCompletion structure to its default values, setting the command tag to unknown and the processed row count to zero.

Definition

void
InitializeQueryCompletion(QueryCompletion *qc)

Detailed Description

This function performs basic initialization of a QueryCompletion structure by setting its fields to safe default values. It sets the commandTag field to CMDTAG_UNKNOWN (which displays as "???") and resets the nprocessed counter to 0. This ensures that QueryCompletion structures start in a predictable state before being populated with actual query execution results.

The function is typically called before executing queries to ensure the completion information starts from a clean state, preventing stale data from previous operations from persisting.

Parameters / Member Variables

  • *qc: Pointer to the QueryCompletion structure to initialize

Dependencies

Notes and Other Information

  • The QueryCompletion structure contains two fields: commandTag (CommandTag enum) and nprocessed (uint64 counter)
  • CMDTAG_UNKNOWN corresponds to the textual representation "???" and has event_trigger_ok=false, table_rewrite_ok=false, rowcount=false
  • This initialization is essential for proper query completion tracking in PostgreSQL's command execution pipeline
  • The function provides a centralized way to ensure consistent initialization across different parts of the codebase

Simplified Source

// Simplified version of InitializeQueryCompletion
void InitializeQueryCompletion(QueryCompletion *qc) {
    // Reset completion structure to safe defaults
    qc->commandTag = CMDTAG_UNKNOWN;
    qc->nprocessed = 0;
}

Key simplifications made:

  • Added clarifying comment about the function's purpose
  • This function is already very simple and straightforward
  • Preserved the essential initialization: unknown command tag and zero row count
  • The core logic is just setting two struct fields to default values