Add limit option to copy function
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t41816psql -h localhost -U postgresBuilt from patchset v1 (message #1), July 28, 2026 at 03:12 AM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t41816_1 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t41816_1 && git checkout t41816_1Patchset v1 (message #1) is on t41816_1
=?UTF-8?B?6rmA64yA7Zi4?= <daiho1.kim@samsung.com> writes:
I suggest adding a limit option to the copy function that limits count of input/output.
I think this will be useful for testing with sample data.
I'm quite skeptical of the value of this. On the output side, you
can already do it with
COPY (SELECT ... LIMIT n) TO wherever;
Moreover, that approach allows you to include an ORDER BY, which is
generally good practice in any query that includes LIMIT, in case
you'd like deterministic results.
On the input side, it's true that you'd have to resort to some
outside features (perhaps applying "head" to the input file, or
some such), or else copy the data into a temp table and post-process.
But that's true for most ways that you might want to adjust or
filter the input data; why should this one be different?
We don't consider that COPY is a general-purpose ETL engine, and
have resisted addition of features to it in the past because
they'd slow down the primary use-case. That objection applies
here too. Yeah, it's (probably) not a big slowdown ... but it's
hard to justify any cost at all for a feature that is outside
the design scope of COPY.
regards, tom lane