Skip to content

[Bug]: pub+fulltext index,can not use select * from where match() against() - #21836

Closed
cpegeric wants to merge 1 commit into
matrixorigin:mainfrom
cpegeric:pub-20210
Closed

cpegeric wants to merge 1 commit into
matrixorigin:mainfrom
cpegeric:pub-20210

Conversation

@cpegeric

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

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

@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label May 13, 2025
@mergify mergify Bot added the kind/bug Something isn't working label May 13, 2025
@cpegeric
cpegeric marked this pull request as draft May 13, 2025 09:49

@aunjgr aunjgr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retracted: this PR is a draft and is excluded from this review pass. No review was performed.

mergify Bot pushed a commit that referenced this pull request Aug 4, 2026
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 XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@matrix-meow matrix-meow added size/XS Denotes a PR that changes [1, 9] lines and removed size/S Denotes a PR that changes [10,99] lines labels Sep 9, 2026
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
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
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
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
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
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
@cpegeric cpegeric closed this Sep 29, 2026

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XS Denotes a PR that changes [1, 9] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants