Repository navigation
Merge upstream v0.6.2 + investigação das queries de prod do sybase_fdw - #2
Merged
Merged
Conversation
* feat(mongodb_fdw): add cargo feature and dependencies * ci(mongodb_fdw): add mongo:7 service to native docker-compose * feat(mongodb_fdw): scaffold module, error type, README * feat(mongodb_fdw): implement BSON to Cell type mapping * feat(mongodb_fdw): implement Cell to BSON write-path mapping * feat(mongodb_fdw): qual/sort/limit/projection deparse helpers * feat(mongodb_fdw): implement begin_scan, iter_scan, re_scan * test(mongodb_fdw): smoketest covering count, lookup, missing field Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(mongodb_fdw): pushdown operators, sort, limit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(mongodb_fdw): _doc jsonb column reads full document * feat(mongodb_fdw): implement begin_modify, insert Add write-path support: begin_modify captures the target database/collection and rowid_column from table options; insert builds a BSON Document from the Row (skipping _doc and null fields) and calls insert_one; end_modify clears the modify target. Includes a pg_test that seeds a collection, inserts a new document via SQL INSERT, and verifies it is readable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(mongodb_fdw): implement update and delete Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(mongodb_fdw): ObjectId hex round-trip on read and qual * docs(mongodb_fdw): add catalog page Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore(mongodb_fdw): cargo fmt * fix(mongodb_fdw): use per-test collection names to avoid parallel-test races * fix(docker-compose): rename mongo service to mongodb for consistency * test(mongodb_fdw): add comprehensive type conversion tests Add mongodb_types_read and mongodb_types_write pg_tests covering all bson_to_cell and cell_to_bson conversion paths: int2/4/8, float4/8, numeric (Decimal128/Double/Int64), text, ObjectId, timestamp, timestamptz, jsonb (Document and Array), and bytea on read; bool, i2, i4, i8, f4, f8, numeric, text, timestamp, timestamptz, and jsonb on the write round-trip. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(mongodb_fdw): enable dns-resolver for mongodb+srv URIs and surface underlying error * fix(mongodb_fdw): sanitize error messages to prevent credential leakage * fix(tests): update float values in BSON tests for accuracy * feat(mongodb): add MongoDB FDW entry to the README * fix(mongodb_fdw): address PR review feedback - bson_to_cell: use try_from for INT2/INT4 conversions so out-of-range BSON integers error instead of silently wrapping - cell_to_bson: return Result and error on unsupported Cell variants instead of silently encoding Bson::Null (prevents write data loss) - iter_scan: drop cursor borrow before iterating tgt_cols to remove the per-row clone of the column list - validator: also check server options — exactly one of conn_string or conn_string_id must be set - docs: clarify that arbitrary OR predicates are not pushed down; only IN / NOT IN array forms become $in / $nin --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
) * feat(openapi_fdw): session variable auth override for per-request credentials Adds `auth_token_setting` and `auth_token_prefix` server options to the OpenAPI FDW, allowing a Postgres session configuration variable to supply the authentication credential at query time rather than at server creation. The credential is resolved via `current_setting(name, true)` each time a request is made, so a security-definer wrapper function can inject a per-user or per-transaction token via `set_config(..., true)` before querying the foreign table. An empty or absent setting is a no-op, preserving any static credential configured at server level. Implementation: - Add `query-setting` to the utils WIT interface (v1 + v2) - Implement `query_setting()` in supabase-wrappers via SPI - Wire host binding in wasm_fdw/host/utils.rs (v1 + v2) - Add `auth_token_setting` / `auth_token_prefix` fields to ServerConfig - Extract `apply_session_token()` as a pure testable helper - Apply override in `make_request` before each HTTP call - Add 15 unit tests covering all override edge cases * test(openapi_fdw): integration test for session-token injection Adds a pgrx integration test exercising the auth_token_setting path end-to-end: with a session GUC unset the FDW injects no Authorization header, and after set_config(...) the resolved token is sent prefixed. This is the only runtime coverage of the query-setting host function -> SPI -> guest round-trip; the existing unit tests only cover the pure apply_session_token helper in isolation. - wasm_fdw/tests.rs: new #[pg_test] openapi_session_token_injection (negative + positive cases) against the local mock on :8096 - dockerfiles/wasm/server.py: add /whoami route that reflects the received Authorization header so the test can assert on it * fix(openapi_fdw): address review feedback - apply_session_token: match the authorization header case-insensitively so a static Authorization header (e.g. from the headers option) is replaced rather than duplicated - query_setting: report unexpected SPI errors instead of swallowing them, matching get_vault_secret (still returns None; absent settings are not errors thanks to current_setting(name, true)) - configure_auth: treat an empty/whitespace auth_token_setting as unset to avoid a pointless per-request lookup, and trim auth_token_prefix - tests: rename the prefix-default test to reflect the empty struct default, add a case-insensitive replace regression test * docs: document session-variable auth - openapi.md: auth_token_setting / auth_token_prefix server options, updated authentication limitation, and a per-request credentials example - wasm-advanced.md: new Host functions section documenting the utils interface, including query_setting for reading session GUCs - openapi_fdw README: note per-request session-variable tokens --------- Co-authored-by: Cody Bromley <codybrom@users.noreply.github.com>
…ation (supabase#603) * chore: bump openapi_fdw version to 0.2.1 and update documentation * chore: bump openapi_fdw package version to 0.2.1 * chore: bump openapi_fdw version to 0.2.1
* fix(mysql_fdw): sanitize MySQL error details * chore(mysql_fdw): remove tests for error report --------- Co-authored-by: Bo Lu <lv.patrick@gmail.com>
* fix(mysql_fdw): support varchar and bpchar text columns * chore(mysql): add more tests and increase fdw version --------- Co-authored-by: Bo Lu <lv.patrick@gmail.com>
…archar/bpchar + sanitize # Conflicts: # Cargo.lock
…bson, mongocrypt) O cargo resolveu as novas dependências trazidas pelo mongodb_fdw (supabase#606) do upstream no primeiro build. Completa o merge da v0.6.2. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
O planner do Postgres empurra o operador ILIKE (`~~*`) como qual de foreign scan, mas o `deparse_qual_to_sybase` caía no framework (que só mapeia `~~`→LIKE) e emitia `~~*` literal. O SQL Anywhere rejeita: "SQL Anywhere Error -131: Syntax error near '~'" — quebrando qualquer query com ILIKE empurrável numa foreign column. (Em prod a query de syscolumns só não estoura porque o OFFSET impede o pushdown; a forma corrigida com WHERE inline faria o ILIKE empurrar e quebrar.) Traduz `~~*`→`UPPER(col) LIKE UPPER(pat)` e `!~~*`→`UPPER(col) NOT LIKE UPPER(pat)` — case-insensitive independente da collation do banco. `~~`/`!~~` seguem indo pro framework (LIKE/NOT LIKE) sem alteração. Reproduzido em .ci/sybase-test-env/fixtures/142; +2 unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Estende o ambiente .ci/sybase-test-env para reproduzir e medir o pushdown das 12 formas problemáticas capturadas em produção: - 9 tabelas bethadba faltantes (ctvlancto, efsdoimp, efsdoimp_por_recolhimento, efparametro_vigencia, geimposto, geimposto_vigencia, foprovisoes, foprovisoes_valores, foempregados_alteracao_contratual) + dados sintéticos, em sql/03_* e sql/04_*, com FTs correspondentes em setup-pg.sql e o alvo `make setup-sa-extra`. - 9 fixtures fixtures/140-148 (as demais famílias — #4/supabase#9/supabase#10 — já cobertas por 118/121/122/119/120). Cada uma asserta o pushdown via EXPLAIN VERBOSE (Wrappers: quals/aggregates, SybaseFdw Join) e guarda tempo com statement_timeout. Suíte: 45 passed. Achados: qual pushdown (IN/NOT IN/BETWEEN/<=/>=) e aggregate pushdown de coluna simples (MAX/SUM/COUNT + GROUP BY) funcionam; #1 SUM(CASE) não empurra (limitação do core em upper.rs, que só aceita agregação sobre T_Var); #6 vira Nested Loop parametrizado (não full-scan). Ver fixture 142 para o fix de ILIKE que acompanha. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Traz o fork para o
upstream/main(v0.6.2) e investiga as 12 famílias de queries de produção dosybase_fdwque estavam problemáticas.Parte 1 — Merge do upstream v0.6.2
Merge de
supabase/wrappers@main(10 commits). Sem conflito de código; sóCargo.lock(regenerado). Novidades: MongoDB FDW (novo, nativo), credenciais por-request via session variables (query_settingno core + openapi wasm), mysql_fdw passa a tratar VARCHAR/BPCHAR e sanitiza mensagens de erro. Trabalho próprio do fork (sybase_fdw, mudanças no core) preservado.Validado no PostgreSQL 18 (toolchain instalada do zero):
supabase-wrappers(unit)sybase_fdw(unit)mongodb_fdw(pgrx)mysql_fdwsmoketest + aggregatenative_fdwsNota: o
mysql_fdwtem uma sensibilidade a timezone pré-existente (código do upstream) na conversão de DATE — passa em servidor UTC; não é regressão do merge.Parte 2 — Investigação das queries de prod (
Temp.sql)Reproduzi as 12 famílias contra o SQL Anywhere sintético (
.ci/sybase-test-env), medindo o pushdown real viaEXPLAIN VERBOSE. Suíte: 45 passed, 0 failed (36 existentes + 9 novas).bethadbafaltantes + dados sintéticos (sql/03_*,04_*) + FTs +make setup-sa-extra.fixtures/140-148reproduzindo cada família.Veredito: qual pushdown (IN/NOT IN/BETWEEN/<=/>=) e aggregate pushdown de coluna simples (MAX/SUM/COUNT + GROUP BY) funcionam; formas correlacionadas (#2/supabase#9/supabase#11/supabase#12) são do app; #1
SUM(CASE)não empurra (limitação do coreupper.rs, que só aceita agregação sobre coluna simples — fix exigiria deparse geral de expressões, deferido).🐞 Bug corrigido: deparse de ILIKE
ILIKE(~~*) era empurrado mas deparsado para SQL Sybase inválido (Error -131: Syntax error near '~'), quebrando qualquer query com ILIKE empurrável numa foreign column. Corrigido paraUPPER(col) LIKE UPPER(pat)+ 2 unit tests. É pré-requisito da correção app-side recomendada para #5.Pendências conhecidas (follow-up)
make bootstraptem um bug de shell nosetup-sado Makefile ($fvazio →/tmp/.sql); schema carregado manualmente nesta investigação.SUM(CASE): recomendação app-side (materialização de saldo de abertura) ou prototipar expression-pushdown no core.🤖 Generated with Claude Code