Repository navigation
Conversation
Publication FULLTEXT rewrites currently serialize the published source table and its hidden index table as SQL strings, then execute that SQL with the subscriber account. Ordinary subscription scans retain publisher identity in `ObjectRef.PubInfo`, but the FULLTEXT `FUNCTION_SCAN` loses it. This change: - resolves the hidden FULLTEXT index through the published source `ObjectRef`; - carries planner-trusted source/index references through TableFunction, Apply, duplicate, and remote pipeline protobuf paths; - validates that both references agree on publisher tenant, database, and subscription; - runs batch and streaming internal SQL with the publisher account/database while preserving the original transaction, snapshot context, cancellation, timezone, and variable resolver; - keeps direct/current-tenant `fulltext_index_scan` calls on their existing identity and prevents SQL string arguments from selecting an account; - preserves prepared-plan dependencies for the source table, hidden index, and subscription; - adds Publication + FULLTEXT BVT coverage for table/database publication, different aliases, quoted identifiers, two subscribers, index maintenance visibility, access denial, and prepared revoke/drop invalidation. This supersedes/integrates the intent of #21836. It does not modify or take over that third-party Draft PR. ### Evidence - Base `6091b418fd529badca4e1855843bd38804de396f`: ordinary subscriber scan passed, but authorized subscriber `MATCH ... AGAINST` failed with `Unknown database publisher_db`. - Head `f74b13cad1b817ad410b71f7504954727c3fc73a`: the same production query passed. Live coverage also verified table/database publications, different aliases, quoted identifiers, two subscribers, insert/update/delete visibility, unpublished-table and catalog denial, prepared revoke/drop failure, and reauthorization recovery. - Passed: - `go test -p=1 ./pkg/sql/plan` - `go test -p=1 ./pkg/sql/compile` - `go test -p=1 ./pkg/sql/colexec/table_function` - `go test -p=1 ./pkg/vectorindex/sqlexec` - `go list`, `go build`, and `go vet` for the four affected packages - `make build` - `git diff --check` ### Security boundary Only planner-resolved `ObjectRef.PubInfo` can enable the publisher override. Runtime rejects partial or conflicting trusted references. The subscriber still cannot read unpublished publisher tables, hidden index tables, or publisher catalog rows. ### QA QA required: yes. The checked-in BVT and protobuf round-trip tests are complete, but multi-CN placement, concurrent subscribers, index-update visibility, and revoke/drop must still be run in the distributed QA environment. Keep issue #20210 open through `phase/testing` until QA PASS. Approved by: @XuPeng-SH, @heni02
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed 37f4330; REQUEST_CHANGES. The schema-name substitution alone does not close the subscriber-to-publisher execution boundary.
[P1] The fulltext table function reads postings through the internal SQL executor, which does not resolve subscription aliases at this head. The changed lines in apply_indices_fulltext.go:235-245 pass subscriptionName.hidden_index (and the source alias) as strings. fulltext.go calls sqlexec.RunSql/RunStreamingSql; those retain proc.Ctx's account ID. In pkg/sql/compile/sql_executor_context.go, GetSubscriptionMeta returns nil and getRelation directly opens engine.Database(ctx, dbName).Relation(ctx, tableName); it does not translate the subscription alias into the publisher database/account as the frontend resolver does. The generated posting query therefore still lacks the publisher identity, and a subscription database does not own the publisher's physical hidden index table.
Fix the resolution/execution contract, not only the display name: carry the validated publisher account/database and authorized base-table/index identity into the internal read, or use a subscription-aware resolver for this internal operation. Scope the authority to the published base table and its owned index; do not broadly bypass publication membership checks. Reuse DbNameOfObjRef for ordinary alias selection where applicable, and use identifier quoting rather than raw backtick interpolation for names.
Required regression is the actual #20210 two-account selective-publication scenario (publisher database and subscriber alias deliberately different), executed through MATCH, with exact row results and scoring/source-count access. Include an ordinary-table control and a negative unpublished-table case. This PR contains no test change or runtime validation evidence, so the ten-line planner edit alone cannot demonstrate the reported failure is fixed.
Evidence: complete one-file diff inspected and followed through the exact-head fulltext, sqlexec, internal compiler resolver and frontend subscription resolver. This is source-level execution-path analysis, not a freshly executed two-account reproduction. Keep Draft until that path and regression are closed.
Publication FULLTEXT rewrites currently serialize the published source table and its hidden index table as SQL strings, then execute that SQL with the subscriber account. Ordinary subscription scans retain publisher identity in `ObjectRef.PubInfo`, but the FULLTEXT `FUNCTION_SCAN` loses it. This change: - resolves the hidden FULLTEXT index through the published source `ObjectRef`; - carries planner-trusted source/index references through TableFunction, Apply, duplicate, and remote pipeline protobuf paths; - validates that both references agree on publisher tenant, database, and subscription; - runs batch and streaming internal SQL with the publisher account/database while preserving the original transaction, snapshot context, cancellation, timezone, and variable resolver; - keeps direct/current-tenant `fulltext_index_scan` calls on their existing identity and prevents SQL string arguments from selecting an account; - preserves prepared-plan dependencies for the source table, hidden index, and subscription; - adds Publication + FULLTEXT BVT coverage for table/database publication, different aliases, quoted identifiers, two subscribers, index maintenance visibility, access denial, and prepared revoke/drop invalidation. This supersedes/integrates the intent of matrixorigin#21836. It does not modify or take over that third-party Draft PR. ### Evidence - Base `6091b418fd529badca4e1855843bd38804de396f`: ordinary subscriber scan passed, but authorized subscriber `MATCH ... AGAINST` failed with `Unknown database publisher_db`. - Head `f74b13cad1b817ad410b71f7504954727c3fc73a`: the same production query passed. Live coverage also verified table/database publications, different aliases, quoted identifiers, two subscribers, insert/update/delete visibility, unpublished-table and catalog denial, prepared revoke/drop failure, and reauthorization recovery. - Passed: - `go test -p=1 ./pkg/sql/plan` - `go test -p=1 ./pkg/sql/compile` - `go test -p=1 ./pkg/sql/colexec/table_function` - `go test -p=1 ./pkg/vectorindex/sqlexec` - `go list`, `go build`, and `go vet` for the four affected packages - `make build` - `git diff --check` ### Security boundary Only planner-resolved `ObjectRef.PubInfo` can enable the publisher override. Runtime rejects partial or conflicting trusted references. The subscriber still cannot read unpublished publisher tables, hidden index tables, or publisher catalog rows. ### QA QA required: yes. The checked-in BVT and protobuf round-trip tests are complete, but multi-CN placement, concurrent subscribers, index-update visibility, and revoke/drop must still be run in the distributed QA environment. Keep issue matrixorigin#20210 open through `phase/testing` until QA PASS. Approved by: @XuPeng-SH, @heni02
Publication FULLTEXT rewrites currently serialize the published source table and its hidden index table as SQL strings, then execute that SQL with the subscriber account. Ordinary subscription scans retain publisher identity in `ObjectRef.PubInfo`, but the FULLTEXT `FUNCTION_SCAN` loses it. This change: - resolves the hidden FULLTEXT index through the published source `ObjectRef`; - carries planner-trusted source/index references through TableFunction, Apply, duplicate, and remote pipeline protobuf paths; - validates that both references agree on publisher tenant, database, and subscription; - runs batch and streaming internal SQL with the publisher account/database while preserving the original transaction, snapshot context, cancellation, timezone, and variable resolver; - keeps direct/current-tenant `fulltext_index_scan` calls on their existing identity and prevents SQL string arguments from selecting an account; - preserves prepared-plan dependencies for the source table, hidden index, and subscription; - adds Publication + FULLTEXT BVT coverage for table/database publication, different aliases, quoted identifiers, two subscribers, index maintenance visibility, access denial, and prepared revoke/drop invalidation. This supersedes/integrates the intent of matrixorigin#21836. It does not modify or take over that third-party Draft PR. ### Evidence - Base `6091b418fd529badca4e1855843bd38804de396f`: ordinary subscriber scan passed, but authorized subscriber `MATCH ... AGAINST` failed with `Unknown database publisher_db`. - Head `f74b13cad1b817ad410b71f7504954727c3fc73a`: the same production query passed. Live coverage also verified table/database publications, different aliases, quoted identifiers, two subscribers, insert/update/delete visibility, unpublished-table and catalog denial, prepared revoke/drop failure, and reauthorization recovery. - Passed: - `go test -p=1 ./pkg/sql/plan` - `go test -p=1 ./pkg/sql/compile` - `go test -p=1 ./pkg/sql/colexec/table_function` - `go test -p=1 ./pkg/vectorindex/sqlexec` - `go list`, `go build`, and `go vet` for the four affected packages - `make build` - `git diff --check` ### Security boundary Only planner-resolved `ObjectRef.PubInfo` can enable the publisher override. Runtime rejects partial or conflicting trusted references. The subscriber still cannot read unpublished publisher tables, hidden index tables, or publisher catalog rows. ### QA QA required: yes. The checked-in BVT and protobuf round-trip tests are complete, but multi-CN placement, concurrent subscribers, index-update visibility, and revoke/drop must still be run in the distributed QA environment. Keep issue matrixorigin#20210 open through `phase/testing` until QA PASS. Approved by: @XuPeng-SH, @heni02
Publication FULLTEXT rewrites currently serialize the published source table and its hidden index table as SQL strings, then execute that SQL with the subscriber account. Ordinary subscription scans retain publisher identity in `ObjectRef.PubInfo`, but the FULLTEXT `FUNCTION_SCAN` loses it. This change: - resolves the hidden FULLTEXT index through the published source `ObjectRef`; - carries planner-trusted source/index references through TableFunction, Apply, duplicate, and remote pipeline protobuf paths; - validates that both references agree on publisher tenant, database, and subscription; - runs batch and streaming internal SQL with the publisher account/database while preserving the original transaction, snapshot context, cancellation, timezone, and variable resolver; - keeps direct/current-tenant `fulltext_index_scan` calls on their existing identity and prevents SQL string arguments from selecting an account; - preserves prepared-plan dependencies for the source table, hidden index, and subscription; - adds Publication + FULLTEXT BVT coverage for table/database publication, different aliases, quoted identifiers, two subscribers, index maintenance visibility, access denial, and prepared revoke/drop invalidation. This supersedes/integrates the intent of matrixorigin#21836. It does not modify or take over that third-party Draft PR. ### Evidence - Base `6091b418fd529badca4e1855843bd38804de396f`: ordinary subscriber scan passed, but authorized subscriber `MATCH ... AGAINST` failed with `Unknown database publisher_db`. - Head `f74b13cad1b817ad410b71f7504954727c3fc73a`: the same production query passed. Live coverage also verified table/database publications, different aliases, quoted identifiers, two subscribers, insert/update/delete visibility, unpublished-table and catalog denial, prepared revoke/drop failure, and reauthorization recovery. - Passed: - `go test -p=1 ./pkg/sql/plan` - `go test -p=1 ./pkg/sql/compile` - `go test -p=1 ./pkg/sql/colexec/table_function` - `go test -p=1 ./pkg/vectorindex/sqlexec` - `go list`, `go build`, and `go vet` for the four affected packages - `make build` - `git diff --check` ### Security boundary Only planner-resolved `ObjectRef.PubInfo` can enable the publisher override. Runtime rejects partial or conflicting trusted references. The subscriber still cannot read unpublished publisher tables, hidden index tables, or publisher catalog rows. ### QA QA required: yes. The checked-in BVT and protobuf round-trip tests are complete, but multi-CN placement, concurrent subscribers, index-update visibility, and revoke/drop must still be run in the distributed QA environment. Keep issue matrixorigin#20210 open through `phase/testing` until QA PASS. Approved by: @XuPeng-SH, @heni02
What type of PR is this?
Which issue(s) this PR fixes:
issue #20210
What this PR does / why we need it:
fix the resolve the schema name to subscription name when subscription name is not empty