Skip to content

Add DefaultPostgreSQLProviderFeatures with the 65535 placeholder limit - #257

Merged
EnriqueL8 merged 2 commits into
hyperledger-firefly:mainfrom
kaleido-io:postgres-default-features
Oct 26, 2026
Merged

EnriqueL8 merged 2 commits into
hyperledger-firefly:mainfrom
kaleido-io:postgres-default-features

Conversation

@Chengxuan

@Chengxuan Chengxuan commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

PostgreSQL caps a single statement at 65535 bind parameters. The limit comes from the wire protocol. InsertMany already chunks multi-row inserts when SQLFeatures.MaxPlaceholders is set, but every PostgreSQL provider has to remember to set it.

This adds, next to BuildPostgreSQLOptimizedUpsert:

  • PostgreSQLMaxPlaceholders = 65535
  • DefaultPostgreSQLProviderFeatures(), returning DefaultSQLProviderFeatures() with $N placeholders, multi-row insert, MaxPlaceholders and the PostgreSQL optimized upsert builder set

Providers can start from it and add their own features on top (lock SQL, ILIKE, sequence column filtering), for example:

func (psql *Postgres) Features() dbsql.SQLFeatures {
	features := dbsql.DefaultPostgreSQLProviderFeatures()
	features.AcquireLock = func(lockName string) string { ... }
	return features
}

No behavior changes for existing callers.

…imit

Signed-off-by: Chengxuan Xing <chengxuan.xing@kaleido.io>
@Chengxuan
Chengxuan requested a review from a team as a code owner October 2, 2026 12:08

@onelapahead onelapahead 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.

This makes sense to me, but might defer to @awrichar on the specific features being proposed as defaults

@awrichar awrichar 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.

Agreed, seems useful.

// DefaultPostgreSQLProviderFeatures are the features shared by PostgreSQL providers, which can add their own on top
func DefaultPostgreSQLProviderFeatures() SQLFeatures {
features := DefaultSQLProviderFeatures()
features.PlaceholderFormat = sq.Dollar

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.

Is this a change in behaviour by default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no. Everything in this function is not picked up automatically. It provides a template that can be used to build the sql feature in the client code.

Signed-off-by: Chengxuan Xing <chengxuan.xing@kaleido.io>
@Chengxuan
Chengxuan force-pushed the postgres-default-features branch from 470e4a0 to 7c73deb Compare October 26, 2026 11:10

@EnriqueL8 EnriqueL8 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.

Thanks @Chengxuan

@EnriqueL8
EnriqueL8 merged commit 96767b6 into hyperledger-firefly:main Oct 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants