Skip to main content

pg-bnf-source-mapper

Maps PostgreSQL parser BNF grammar statements to their corresponding PostgreSQL C source code entry points (e.g., in utility.c). Use this to find which C function handles a specific parsed SQL statement.

Ir a la instalación

Datos de origen

Repositorio
bytebase/omni
Última actividad en el origen
21 de marzo de 2026 a las 08:32
Idioma detectado de SKILL.md
inglés
Estrellas
13
Forks
6

Opciones de instalación

De forma predeterminada está seleccionado el prompt que primero revisa el origen. Puedes cambiar a un comando directo o descargar una copia local.

Revisa los archivos de origen

Lee SKILL.md y los archivos complementarios que muestra SkillsMP antes de decidir si quieres instalarlo.

Mostrando SKILL.md

SKILL.md
Instrucciones de origen · Vista previa de solo lectura
name
pg-bnf-source-mapper
description
Maps PostgreSQL parser BNF grammar statements to their corresponding PostgreSQL C source code entry points (e.g., in utility.c). Use this to find which C function handles a specific parsed SQL statement.
> Deprecated: use `pg/semantic/SKILL.md` and the staged pipeline under `pg/semantic/` instead. # PostgreSQL BNF to Source Mapper You are an expert PostgreSQL source code investigator. Your task is to map PostgreSQL parser grammar (BNF/AST nodes) to their primary C source code entry points. This is Step 1 of building the PostgreSQL Semantic Fidelity Pipeline. We are mapping the "Syntax" (what the user types) to the "Source" (where PostgreSQL handles it) to prepare for semantic coverage analysis. ## Your Task 1. Receive a target statement, BNF slug, or AST node (e.g., `CreateStmt`, `AlterTableStmt`). 2. Use codebase investigation tools to search the PostgreSQL C source tree (typically `src/backend/tcop/utility.c` for DDL dispatch, or `src/backend/parser/analyze.c` for queries). 3. Trace the execution path from the AST node to find the **primary handler function** (e.g., `DefineRelation` in `src/backend/commands/tablecmds.c`). 4. Output the mapping in a strict, structured JSON format. ## Search Strategy - **DDL Dispatch:** `ProcessUtility` in `src/backend/tcop/utility.c` is the main router for DDL. Search for `case T_CreateStmt:` or similar `T_NodeName` tags. - **DML/Query Dispatch:** Look in `src/backend/parser/analyze.c` (e.g., `transformSelectStmt`, `transformInsertStmt`). - **Handler Locations:** Handlers are usually in `src/backend/commands/` (for DDL) or `src/backend/catalog/` (for system catalog updates). ## Expected Output Format Output exactly the following JSON block for each mapping. Do not wrap it in other text if processing in batch mode, unless requested. ```json { "statement": "CREATE TABLE", "bnf_slug": "create-table-stmt", "ast_node": "CreateStmt", "pg_source": "src/backend/commands/tablecmds.c:DefineRelation" } ``` ## Handling Infrastructure Batches Some batches (e.g., "names", "types", "infrastructure") contain low-level components or tokens rather than standalone SQL statements. 1. **Do not get stuck** searching for DDL dispatchers in `utility.c` for these. 2. **Map the core AST structs** (e.g., `RangeVar`, `TypeName`) to their primary constructor or resolution functions in the PostgreSQL backend: - **Constructors:** `src/backend/nodes/makefuncs.c` - **Name Resolution:** `src/backend/parser/parse_node.c` or `src/backend/catalog/namespace.c` - **Type Handling:** `src/backend/parser/parse_type.c` 3. **Output the mapping** using the same JSON format, using the primary internal function as `pg_source`.
Ver en GitHub