agora inbox for pgsql-hackers@postgresql.org
help / color / mirror / Atom feedBUG #3774: create table like including index doesn't update pg_constraints with primary key
21+ messages / 6 participants
[nested] [flat]
* BUG #3774: create table like including index doesn't update pg_constraints with primary key
@ 2007-11-22 17:47 guillaume (ioguix) de Rorthais <ioguix@free.fr>
0 siblings, 2 replies; 21+ messages in thread
From: guillaume (ioguix) de Rorthais @ 2007-11-22 17:47 UTC (permalink / raw)
To: pgsql-bugs@postgresql.org
The following bug has been logged online:
Bug reference: 3774
Logged by: guillaume (ioguix) de Rorthais
Email address: ioguix@free.fr
PostgreSQL version: 8.3 beta3
Operating system: mac os x 10.4.10
Description: create table like including index doesn't update
pg_constraints with primary key
Details:
When creating a table using the "create table ... (like ... inluding
indexes...)" syntaxe, pg_catalog.pg_constraint is not updated with the PK
constraints which actually is setted in pg_index.
Here is my test script :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pagila=# --the original table
\d city
Table "public.city"
Column | Type | Modifiers
-------------+-----------------------------+--------------------------------
------------------------
city_id | integer | not null default
nextval('city_city_id_seq'::regclass)
city | character varying(50) | not null
country_id | smallint | not null
last_update | timestamp without time zone | not null default now()
Indexes:
"city_pkey" PRIMARY KEY, btree (city_id)
"idx_fk_country_id" btree (country_id)
Foreign-key constraints:
"city_country_id_fkey" FOREIGN KEY (country_id) REFERENCES
country(country_id) ON UPDATE CASCADE ON DELETE RESTRICT
Triggers:
last_updated BEFORE UPDATE ON city FOR EACH ROW EXECUTE PROCEDURE
last_updated()
pagila=# -- its pk constraint in pg_constraint
SELECT relname,
conname, contype
FROM pg_class cl
JOIN pg_constraint co ON (cl.oid=co.conrelid)
JOIN pg_namespace n ON (cl.relnamespace=n.oid)
WHERE
cl.relname='city' AND n.nspname='public' AND contype='p';
relname | conname | contype
---------+-----------+---------
city | city_pkey | p
(1 row)
pagila=# -- create the new table citylike like city
CREATE TABLE
citylike (LIKE city INCLUDING INDEXES INCLUDING DEFAULTS);
CREATE TABLE
pagila=# --the citylike table
\d citylike
Table "public.citylike"
Column | Type | Modifiers
-------------+-----------------------------+--------------------------------
------------------------
city_id | integer | not null default
nextval('city_city_id_seq'::regclass)
city | character varying(50) | not null
country_id | smallint | not null
last_update | timestamp without time zone | not null default now()
Indexes:
"citylike_pkey" PRIMARY KEY, btree (city_id)
"citylike_country_id_key" btree (country_id)
pagila=# -- citylike constraints'
pagila=# SELECT relname, conname, contype
FROM
pg_class cl
JOIN pg_constraint co
ON (cl.oid=co.conrelid)
JOIN pg_namespace n ON
(cl.relnamespace=n.oid)
WHERE cl.relname='citylike' AND
n.nspname='public' AND contype='p';
relname | conname | contype
---------+---------+---------
(0 rows)
pagila=#
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm not sure if this issue is actually a bug or if there a logic behind
this, but as the primary key is a constraint, I would expect it to be setted
in pg_constraint, shouldn't it ?
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: BUG #3774: create table like including index doesn't update pg_constraints with primary key
@ 2007-11-30 07:44 NikhilS <nikkhils@gmail.com>
parent: guillaume (ioguix) de Rorthais <ioguix@free.fr>
1 sibling, 1 reply; 21+ messages in thread
From: NikhilS @ 2007-11-30 07:44 UTC (permalink / raw)
To: ioguix@free.fr; +Cc: pgsql-bugs@postgresql.org; pgsql-hackers
Hi,
>
> The following bug has been logged online:
>
> Bug reference: 3774
> Logged by: guillaume (ioguix) de Rorthais
> Email address: ioguix@free.fr
> PostgreSQL version: 8.3 beta3
> Operating system: mac os x 10.4.10
> Description: create table like including index doesn't update
> pg_constraints with primary key
> Details:
>
> When creating a table using the "create table ... (like ... inluding
> indexes...)" syntaxe, pg_catalog.pg_constraint is not updated with the PK
> constraints which actually is setted in pg_index.
>
> I'm not sure if this issue is actually a bug or if there a logic behind
> this, but as the primary key is a constraint, I would expect it to be
> setted
> in pg_constraint, shouldn't it ?
>
This can be handled by setting index->isconstraint appropriately inside
generateClonedIndexStmt().
The fundamental question though is should we allow primary, unique
CONSTRAINTS which use the index mechanism just as an implementation to be
created using the "INCLUDING INDEXES" mechanism.
As per the discussion here:
http://www.nabble.com/Re%3A-CREATE-TABLE-LIKE-INCLUDING-INDEXES-support-p10683716.html
maybe we should not?
In other words "INCLUDING INDEXES" should only create those indexes which do
not have isconstraint set to TRUE.
Comments?
Regards,
Nikhils
--
EnterpriseDB http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: [HACKERS] BUG #3774: create table like including index doesn't update pg_constraints with primary key
@ 2007-12-01 23:46 Tom Lane <tgl@sss.pgh.pa.us>
parent: NikhilS <nikkhils@gmail.com>
0 siblings, 1 reply; 21+ messages in thread
From: Tom Lane @ 2007-12-01 23:46 UTC (permalink / raw)
To: NikhilS <nikkhils@gmail.com>; +Cc: ioguix@free.fr; pgsql-bugs@postgresql.org; pgsql-hackers
NikhilS <nikkhils@gmail.com> writes:
> This can be handled by setting index->isconstraint appropriately inside
> generateClonedIndexStmt().
Done.
> The fundamental question though is should we allow primary, unique
> CONSTRAINTS which use the index mechanism just as an implementation to be
> created using the "INCLUDING INDEXES" mechanism.
Yeah, this bizarreness was foreseen and agreed to back when we set up
LIKE INCLUDING CONSTRAINTS the way it was defined (ie, copying only
CHECK constraints and not other things called constraints). I was never
very thrilled with that definition myself, but it's a bit too late to
revisit it.
regards, tom lane
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: [HACKERS] BUG #3774: create table like including index doesn't update pg_constraints with primary key
@ 2007-12-02 08:14 NikhilS <nikkhils@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 21+ messages in thread
From: NikhilS @ 2007-12-02 08:14 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Bruce Momjian <bruce@momjian.us>; +Cc: ioguix@free.fr; pgsql-bugs@postgresql.org; pgsql-hackers
Hi,
>
> > The fundamental question though is should we allow primary, unique
> > CONSTRAINTS which use the index mechanism just as an implementation to
> be
> > created using the "INCLUDING INDEXES" mechanism.
>
> Yeah, this bizarreness was foreseen and agreed to back when we set up
> LIKE INCLUDING CONSTRAINTS the way it was defined (ie, copying only
> CHECK constraints and not other things called constraints). I was never
> very thrilled with that definition myself, but it's a bit too late to
> revisit it.
>
Yeah this is all confusing. I believe we should remove the following TODO
now that the above has been checked in:
CREATE
- Have WITH CONSTRAINTS also create constraint indexes
http://archives.postgresql.org/pgsql-patches/2007-04/msg00149.php
Regards,
Nikhils
--
EnterpriseDB http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: BUG #3774: create table like including index doesn't update pg_constraints with primary key
@ 2007-12-13 00:34 Bruce Momjian <bruce@momjian.us>
parent: guillaume (ioguix) de Rorthais <ioguix@free.fr>
1 sibling, 1 reply; 21+ messages in thread
From: Bruce Momjian @ 2007-12-13 00:34 UTC (permalink / raw)
To: guillaume (ioguix) de Rorthais <ioguix@free.fr>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs@postgresql.org
Tom, did your recent commit to clean up LIKE ... INCLUDING INDEXES fix
this?
---------------------------------------------------------------------------
guillaume (ioguix) de Rorthais wrote:
>
> The following bug has been logged online:
>
> Bug reference: 3774
> Logged by: guillaume (ioguix) de Rorthais
> Email address: ioguix@free.fr
> PostgreSQL version: 8.3 beta3
> Operating system: mac os x 10.4.10
> Description: create table like including index doesn't update
> pg_constraints with primary key
> Details:
>
> When creating a table using the "create table ... (like ... inluding
> indexes...)" syntaxe, pg_catalog.pg_constraint is not updated with the PK
> constraints which actually is setted in pg_index.
>
> Here is my test script :
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> pagila=# --the original table
>
> \d city
>
>
>
> Table "public.city"
> Column | Type | Modifiers
>
> -------------+-----------------------------+--------------------------------
> ------------------------
> city_id | integer | not null default
> nextval('city_city_id_seq'::regclass)
> city | character varying(50) | not null
> country_id | smallint | not null
> last_update | timestamp without time zone | not null default now()
> Indexes:
> "city_pkey" PRIMARY KEY, btree (city_id)
> "idx_fk_country_id" btree (country_id)
> Foreign-key constraints:
> "city_country_id_fkey" FOREIGN KEY (country_id) REFERENCES
> country(country_id) ON UPDATE CASCADE ON DELETE RESTRICT
> Triggers:
> last_updated BEFORE UPDATE ON city FOR EACH ROW EXECUTE PROCEDURE
> last_updated()
>
> pagila=# -- its pk constraint in pg_constraint
>
> SELECT relname,
> conname, contype
>
> FROM pg_class cl
>
>
> JOIN pg_constraint co ON (cl.oid=co.conrelid)
>
>
> JOIN pg_namespace n ON (cl.relnamespace=n.oid)
>
> WHERE
> cl.relname='city' AND n.nspname='public' AND contype='p';
> relname | conname | contype
> ---------+-----------+---------
> city | city_pkey | p
> (1 row)
>
> pagila=# -- create the new table citylike like city
>
> CREATE TABLE
> citylike (LIKE city INCLUDING INDEXES INCLUDING DEFAULTS);
> CREATE TABLE
> pagila=# --the citylike table
>
> \d citylike
> Table "public.citylike"
> Column | Type | Modifiers
>
> -------------+-----------------------------+--------------------------------
> ------------------------
> city_id | integer | not null default
> nextval('city_city_id_seq'::regclass)
> city | character varying(50) | not null
> country_id | smallint | not null
> last_update | timestamp without time zone | not null default now()
> Indexes:
> "citylike_pkey" PRIMARY KEY, btree (city_id)
> "citylike_country_id_key" btree (country_id)
>
> pagila=# -- citylike constraints'
> pagila=# SELECT relname, conname, contype
>
> FROM
> pg_class cl
>
> JOIN pg_constraint co
> ON (cl.oid=co.conrelid)
>
> JOIN pg_namespace n ON
> (cl.relnamespace=n.oid)
>
> WHERE cl.relname='citylike' AND
> n.nspname='public' AND contype='p';
> relname | conname | contype
> ---------+---------+---------
> (0 rows)
>
> pagila=#
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> I'm not sure if this issue is actually a bug or if there a logic behind
> this, but as the primary key is a constraint, I would expect it to be setted
> in pg_constraint, shouldn't it ?
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: BUG #3774: create table like including index doesn't update pg_constraints with primary key
@ 2008-03-06 21:45 Bruce Momjian <bruce@momjian.us>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 21+ messages in thread
From: Bruce Momjian @ 2008-03-06 21:45 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: guillaume (ioguix) de Rorthais <ioguix@free.fr>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs@postgresql.org
Tom, did your commit to clean up LIKE ... INCLUDING INDEXES fix
this?
> ---------------------------------------------------------------------------
>
> guillaume (ioguix) de Rorthais wrote:
> >
> > The following bug has been logged online:
> >
> > Bug reference: 3774
> > Logged by: guillaume (ioguix) de Rorthais
> > Email address: ioguix@free.fr
> > PostgreSQL version: 8.3 beta3
> > Operating system: mac os x 10.4.10
> > Description: create table like including index doesn't update
> > pg_constraints with primary key
> > Details:
> >
> > When creating a table using the "create table ... (like ... inluding
> > indexes...)" syntaxe, pg_catalog.pg_constraint is not updated with the PK
> > constraints which actually is setted in pg_index.
> >
> > Here is my test script :
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > pagila=# --the original table
> >
> > \d city
> >
> >
> >
> > Table "public.city"
> > Column | Type | Modifiers
> >
> > -------------+-----------------------------+--------------------------------
> > ------------------------
> > city_id | integer | not null default
> > nextval('city_city_id_seq'::regclass)
> > city | character varying(50) | not null
> > country_id | smallint | not null
> > last_update | timestamp without time zone | not null default now()
> > Indexes:
> > "city_pkey" PRIMARY KEY, btree (city_id)
> > "idx_fk_country_id" btree (country_id)
> > Foreign-key constraints:
> > "city_country_id_fkey" FOREIGN KEY (country_id) REFERENCES
> > country(country_id) ON UPDATE CASCADE ON DELETE RESTRICT
> > Triggers:
> > last_updated BEFORE UPDATE ON city FOR EACH ROW EXECUTE PROCEDURE
> > last_updated()
> >
> > pagila=# -- its pk constraint in pg_constraint
> >
> > SELECT relname,
> > conname, contype
> >
> > FROM pg_class cl
> >
> >
> > JOIN pg_constraint co ON (cl.oid=co.conrelid)
> >
> >
> > JOIN pg_namespace n ON (cl.relnamespace=n.oid)
> >
> > WHERE
> > cl.relname='city' AND n.nspname='public' AND contype='p';
> > relname | conname | contype
> > ---------+-----------+---------
> > city | city_pkey | p
> > (1 row)
> >
> > pagila=# -- create the new table citylike like city
> >
> > CREATE TABLE
> > citylike (LIKE city INCLUDING INDEXES INCLUDING DEFAULTS);
> > CREATE TABLE
> > pagila=# --the citylike table
> >
> > \d citylike
> > Table "public.citylike"
> > Column | Type | Modifiers
> >
> > -------------+-----------------------------+--------------------------------
> > ------------------------
> > city_id | integer | not null default
> > nextval('city_city_id_seq'::regclass)
> > city | character varying(50) | not null
> > country_id | smallint | not null
> > last_update | timestamp without time zone | not null default now()
> > Indexes:
> > "citylike_pkey" PRIMARY KEY, btree (city_id)
> > "citylike_country_id_key" btree (country_id)
> >
> > pagila=# -- citylike constraints'
> > pagila=# SELECT relname, conname, contype
> >
> > FROM
> > pg_class cl
> >
> > JOIN pg_constraint co
> > ON (cl.oid=co.conrelid)
> >
> > JOIN pg_namespace n ON
> > (cl.relnamespace=n.oid)
> >
> > WHERE cl.relname='citylike' AND
> > n.nspname='public' AND contype='p';
> > relname | conname | contype
> > ---------+---------+---------
> > (0 rows)
> >
> > pagila=#
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > I'm not sure if this issue is actually a bug or if there a logic behind
> > this, but as the primary key is a constraint, I would expect it to be setted
> > in pg_constraint, shouldn't it ?
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/docs/faq
>
> --
> Bruce Momjian <bruce@momjian.us> http://momjian.us
> EnterpriseDB http://postgres.enterprisedb.com
>
> + If your life is a hard drive, Christ can be your backup. +
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
^ permalink raw reply [nested|flat] 21+ messages in thread
* Re: BUG #3774: create table like including index doesn't update pg_constraints with primary key
@ 2008-03-06 22:20 Tom Lane <tgl@sss.pgh.pa.us>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 21+ messages in thread
From: Tom Lane @ 2008-03-06 22:20 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: guillaume (ioguix) de Rorthais <ioguix@free.fr>; pgsql-bugs@postgresql.org
Bruce Momjian <bruce@momjian.us> writes:
> Tom, did your commit to clean up LIKE ... INCLUDING INDEXES fix
> this?
Yes, see 2007-12-01 commit.
regards, tom lane
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v24 03/11] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 24 ++++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 8 +++++++
2 files changed, 32 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index d3acb98d04..edbfd9abc1 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -201,6 +201,30 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+ size | access | modification | change | creation | isdir
+------+--------+--------------+--------+----------+-------
+(0 rows)
+
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 094e8f8296..b32a3a4b74 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -60,6 +60,14 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--mPTHnM80CEnHQ2WJ
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v24-0004-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v22 03/10] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 18 ++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 5 +++++
2 files changed, 23 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index d3acb98d04..2e87c548eb 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -201,6 +201,24 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 094e8f8296..f6857ad177 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -60,6 +60,11 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--d6Gm4EdcadzBjdND
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v22-0004-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v20 03/10] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 18 ++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 5 +++++
2 files changed, 23 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index d3acb98d04..2e87c548eb 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -201,6 +201,24 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 094e8f8296..f6857ad177 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -60,6 +60,11 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--Z1Z8UV8BNhgCynIS
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v20-0004-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v21 03/10] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 18 ++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 5 +++++
2 files changed, 23 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index d3acb98d04..2e87c548eb 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -201,6 +201,24 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 094e8f8296..f6857ad177 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -60,6 +60,11 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--Tcb1KvpfnM4LxW2s
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v21-0004-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v19 03/10] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 18 ++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 5 +++++
2 files changed, 23 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index d3acb98d04..2e87c548eb 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -201,6 +201,24 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 094e8f8296..f6857ad177 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -60,6 +60,11 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--S0GG+JvAI2G0KxBG
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v19-0004-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v15 03/10] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 18 ++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 5 +++++
2 files changed, 23 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index d3acb98d04..2e87c548eb 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -201,6 +201,24 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 094e8f8296..f6857ad177 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -60,6 +60,11 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--8w3uRX/HFJGApMzv
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v15-0004-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v30 02/11] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 24 ++++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 8 +++++++
2 files changed, 32 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index e845042d38..ea0fc48dbd 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -214,6 +214,30 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+ size | access | modification | change | creation | isdir
+------+--------+--------------+--------+----------+-------
+(0 rows)
+
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index a398349afc..eb6ac12ab4 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -69,6 +69,14 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--ZwgA9U+XZDXt4+m+
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v30-0003-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v28 02/11] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 24 ++++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 8 +++++++
2 files changed, 32 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index e845042d38..ea0fc48dbd 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -214,6 +214,30 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+ size | access | modification | change | creation | isdir
+------+--------+--------------+--------+----------+-------
+(0 rows)
+
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index a398349afc..eb6ac12ab4 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -69,6 +69,14 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--vk/v8fjDPiDepTtA
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v28-0003-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v15 03/10] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 18 ++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 5 +++++
2 files changed, 23 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index d3acb98d04..2e87c548eb 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -201,6 +201,24 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 094e8f8296..f6857ad177 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -60,6 +60,11 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--8w3uRX/HFJGApMzv
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v15-0004-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v31 02/11] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 24 ++++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 8 +++++++
2 files changed, 32 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index 1013d17f87..830de507e7 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -243,6 +243,30 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+ size | access | modification | change | creation | isdir
+------+--------+--------------+--------+----------+-------
+(0 rows)
+
--
-- Test replication slot directory functions
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 7ab9b2a150..422a1369ae 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -91,6 +91,14 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+
--
-- Test replication slot directory functions
--
--
2.17.0
--qZVVwWJgpX9Jzs7f
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v31-0003-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v31 02/11] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 24 ++++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 8 +++++++
2 files changed, 32 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index 1013d17f87..830de507e7 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -243,6 +243,30 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+ size | access | modification | change | creation | isdir
+------+--------+--------------+--------+----------+-------
+(0 rows)
+
--
-- Test replication slot directory functions
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 7ab9b2a150..422a1369ae 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -91,6 +91,14 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+
--
-- Test replication slot directory functions
--
--
2.17.0
--qZVVwWJgpX9Jzs7f
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v31-0003-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v30 02/11] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 24 ++++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 8 +++++++
2 files changed, 32 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index e845042d38..ea0fc48dbd 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -214,6 +214,30 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+ size | access | modification | change | creation | isdir
+------+--------+--------------+--------+----------+-------
+(0 rows)
+
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index a398349afc..eb6ac12ab4 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -69,6 +69,14 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--ZwgA9U+XZDXt4+m+
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v30-0003-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH v25 03/11] Add tests on pg_ls_dir before changing it
@ 2020-03-17 18:16 Justin Pryzby <pryzbyj@telsasoft.com>
0 siblings, 0 replies; 21+ messages in thread
From: Justin Pryzby @ 2020-03-17 18:16 UTC (permalink / raw)
---
src/test/regress/expected/misc_functions.out | 24 ++++++++++++++++++++
src/test/regress/sql/misc_functions.sql | 8 +++++++
2 files changed, 32 insertions(+)
diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out
index d3acb98d04..edbfd9abc1 100644
--- a/src/test/regress/expected/misc_functions.out
+++ b/src/test/regress/expected/misc_functions.out
@@ -201,6 +201,30 @@ select count(*) > 0 from
t
(1 row)
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+ name
+------
+ .
+(1 row)
+
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+ name
+------
+(0 rows)
+
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+ pg_ls_dir
+-----------
+(0 rows)
+
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+ERROR: could not open directory "does not exist": No such file or directory
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+ size | access | modification | change | creation | isdir
+------+--------+--------------+--------+----------+-------
+(0 rows)
+
--
-- Test adding a support function to a subject function
--
diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql
index 094e8f8296..b32a3a4b74 100644
--- a/src/test/regress/sql/misc_functions.sql
+++ b/src/test/regress/sql/misc_functions.sql
@@ -60,6 +60,14 @@ select count(*) > 0 from
where spcname = 'pg_default') pts
join pg_database db on pts.pts = db.oid;
+select * from (select pg_ls_dir('.', false, true) as name) as ls where ls.name='.'; -- include_dot_dirs=true
+select * from (select pg_ls_dir('.', false, false) as name) as ls where ls.name='.'; -- include_dot_dirs=false
+select pg_ls_dir('does not exist', true, false); -- ok with missingok=true
+select pg_ls_dir('does not exist'); -- fails with missingok=false
+
+-- Check that expected columns are present
+select * from pg_stat_file('.') limit 0;
+
--
-- Test adding a support function to a subject function
--
--
2.17.0
--SBikYMzjhZGK9d4p
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="v25-0004-Add-pg_ls_dir_metadata-to-list-a-dir-with-file-m.patch"
^ permalink raw reply [nested|flat] 21+ messages in thread
* [PATCH 3/8] Introduce RepackDest structure.
@ 2026-06-16 11:54 Antonin Houska <ah@cybertec.at>
0 siblings, 0 replies; 21+ messages in thread
From: Antonin Houska @ 2026-06-16 11:54 UTC (permalink / raw)
This is for ChangeContext to handle insertions into two relations: besides the
new relation (whose file will eventually be used by the REPACKed relation), an
"auxiliary relation" is needed sometimes, in order to get the data sorted. The
concept is introduced and explained later in the patch series.
---
src/backend/commands/repack.c | 221 ++++++++++++++++---------------
src/include/commands/repack.h | 48 +++++++
src/tools/pgindent/typedefs.list | 1 +
3 files changed, 160 insertions(+), 110 deletions(-)
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index fa98b8b9247..04d39ad8c86 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -93,40 +93,6 @@ typedef struct
Oid indexOid;
} RelToCluster;
-/*
- * The first file exported by the decoding worker must contain a snapshot, the
- * following ones contain the data changes.
- */
-#define WORKER_FILE_SNAPSHOT 0
-
-/*
- * Information needed to apply concurrent data changes.
- */
-typedef struct ChangeContext
-{
- /* The relation the changes are applied to. */
- Relation cc_rel;
-
- /* Needed to update indexes of cc_rel. */
- ResultRelInfo *cc_rri;
- EState *cc_estate;
-
- /*
- * Existing tuples to UPDATE and DELETE are located via this index. We
- * keep the scankey in partially initialized state to avoid repeated work.
- * sk_argument is completed on the fly.
- */
- Relation cc_ident_index;
- ScanKey cc_ident_key;
- int cc_ident_key_nentries;
-
- /* The latest column we need to deform to have the tuple identity */
- AttrNumber cc_last_key_attno;
-
- /* Sequential number of the file containing the changes. */
- int cc_file_seq;
-} ChangeContext;
-
/*
* Backend-local information to control the decoding worker.
*/
@@ -173,22 +139,19 @@ static List *get_tables_to_repack_partitioned(RepackCommand cmd,
static bool repack_is_permitted_for_relation(RepackCommand cmd,
Oid relid, Oid userid);
-static void apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt);
-static void apply_concurrent_insert(Relation rel, TupleTableSlot *slot,
- ChangeContext *chgcxt);
-static void apply_concurrent_update(Relation rel, TupleTableSlot *spilled_tuple,
- TupleTableSlot *ondisk_tuple,
- ChangeContext *chgcxt);
+static void apply_concurrent_changes(ChangeContext *chgcxt);
+static void apply_concurrent_insert(RepackDest *dest, TupleTableSlot *slot);
+static void apply_concurrent_update(RepackDest *dest,
+ TupleTableSlot *spilled_tuple,
+ TupleTableSlot *ondisk_tuple);
static void apply_concurrent_delete(Relation rel, TupleTableSlot *slot);
static void restore_tuple(BufFile *file, Relation relation,
TupleTableSlot *slot);
static void adjust_toast_pointers(Relation relation, TupleTableSlot *dest,
TupleTableSlot *src);
-static bool find_target_tuple(Relation rel, ChangeContext *chgcxt,
- TupleTableSlot *locator,
+static bool find_target_tuple(RepackDest *dest, TupleTableSlot *locator,
TupleTableSlot *retrieved);
-static bool identity_key_equal(ChangeContext *chgcxt,
- TupleTableSlot *locator,
+static bool identity_key_equal(RepackDest *dest, TupleTableSlot *locator,
TupleTableSlot *candidate);
static void process_concurrent_changes(XLogRecPtr end_of_wal,
ChangeContext *chgcxt,
@@ -197,6 +160,9 @@ static void initialize_change_context(ChangeContext *chgcxt,
Relation relation,
Oid ident_index_id);
static void release_change_context(ChangeContext *chgcxt);
+static void initialize_change_dest(RepackDest *dest, Relation relation,
+ Oid ident_index_id);
+static void release_change_dest(RepackDest *dest);
static void rebuild_relation_finish_concurrent(Relation NewHeap, Relation OldHeap,
Oid identIdx,
TransactionId frozenXid,
@@ -2613,18 +2579,31 @@ RepackCommandAsString(RepackCommand cmd)
}
/*
- * Apply all the changes stored in 'file'.
+ * Apply all the changes provided by decoding worker.
*/
static void
-apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt)
+apply_concurrent_changes(ChangeContext *chgcxt)
{
ConcurrentChangeKind kind = '\0';
- Relation rel = chgcxt->cc_rel;
+ RepackDest *dest;
+ Relation rel;
TupleTableSlot *spilled_tuple;
TupleTableSlot *old_update_tuple;
TupleTableSlot *ondisk_tuple;
bool have_old_tuple = false;
MemoryContext oldcxt;
+ DecodingWorkerShared *shared;
+ char fname[MAXPGPATH];
+ BufFile *file;
+
+ dest = &chgcxt->cc_dest;
+ rel = dest->rel;
+
+ shared = (DecodingWorkerShared *) dsm_segment_address(decoding_worker->seg);
+
+ /* Open the file containing the changes. */
+ DecodingWorkerFileName(fname, shared->relid, chgcxt->cc_file_seq);
+ file = BufFileOpenFileSet(&shared->sfs.fs, fname, O_RDONLY, false);
spilled_tuple = MakeSingleTupleTableSlot(RelationGetDescr(rel),
&TTSOpsVirtual);
@@ -2633,7 +2612,7 @@ apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt)
old_update_tuple = MakeSingleTupleTableSlot(RelationGetDescr(rel),
&TTSOpsVirtual);
- oldcxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(chgcxt->cc_estate));
+ oldcxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(dest->estate));
while (true)
{
@@ -2682,14 +2661,14 @@ apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt)
if (kind == CHANGE_INSERT)
{
- apply_concurrent_insert(rel, spilled_tuple, chgcxt);
+ apply_concurrent_insert(dest, spilled_tuple);
}
else if (kind == CHANGE_DELETE)
{
bool found;
/* Find the tuple to be deleted */
- found = find_target_tuple(rel, chgcxt, spilled_tuple, ondisk_tuple);
+ found = find_target_tuple(dest, spilled_tuple, ondisk_tuple);
if (!found)
elog(ERROR, "could not find target tuple");
apply_concurrent_delete(rel, ondisk_tuple);
@@ -2705,7 +2684,7 @@ apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt)
key = spilled_tuple;
/* Find the tuple to be updated or deleted. */
- found = find_target_tuple(rel, chgcxt, key, ondisk_tuple);
+ found = find_target_tuple(dest, key, ondisk_tuple);
if (!found)
elog(ERROR, "could not find target tuple");
@@ -2718,7 +2697,7 @@ apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt)
*/
adjust_toast_pointers(rel, spilled_tuple, ondisk_tuple);
- apply_concurrent_update(rel, spilled_tuple, ondisk_tuple, chgcxt);
+ apply_concurrent_update(dest, spilled_tuple, ondisk_tuple);
ExecClearTuple(old_update_tuple);
have_old_tuple = false;
@@ -2726,7 +2705,7 @@ apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt)
else
elog(ERROR, "unrecognized kind of change: %d", kind);
- ResetPerTupleExprContext(chgcxt->cc_estate);
+ ResetPerTupleExprContext(dest->estate);
}
/* Cleanup. */
@@ -2735,6 +2714,8 @@ apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt)
ExecDropSingleTupleTableSlot(old_update_tuple);
MemoryContextSwitchTo(oldcxt);
+
+ BufFileClose(file);
}
/*
@@ -2742,16 +2723,15 @@ apply_concurrent_changes(BufFile *file, ChangeContext *chgcxt)
* table.
*/
static void
-apply_concurrent_insert(Relation rel, TupleTableSlot *slot,
- ChangeContext *chgcxt)
+apply_concurrent_insert(RepackDest *dest, TupleTableSlot *slot)
{
/* Put the tuple in the table, but make sure it won't be decoded */
- table_tuple_insert(rel, slot, GetCurrentCommandId(true),
+ table_tuple_insert(dest->rel, slot, GetCurrentCommandId(true),
TABLE_INSERT_NO_LOGICAL, NULL);
/* Update indexes with this new tuple. */
- ExecInsertIndexTuples(chgcxt->cc_rri,
- chgcxt->cc_estate,
+ ExecInsertIndexTuples(dest->rri,
+ dest->estate,
0,
slot,
NIL, NULL);
@@ -2763,10 +2743,10 @@ apply_concurrent_insert(Relation rel, TupleTableSlot *slot,
* table.
*/
static void
-apply_concurrent_update(Relation rel, TupleTableSlot *spilled_tuple,
- TupleTableSlot *ondisk_tuple,
- ChangeContext *chgcxt)
+apply_concurrent_update(RepackDest *dest, TupleTableSlot *spilled_tuple,
+ TupleTableSlot *ondisk_tuple)
{
+ Relation rel = dest->rel;
LockTupleMode lockmode;
TM_FailureData tmfd;
TU_UpdateIndexes update_indexes;
@@ -2794,8 +2774,8 @@ apply_concurrent_update(Relation rel, TupleTableSlot *spilled_tuple,
if (update_indexes == TU_Summarizing)
flags |= EIIT_ONLY_SUMMARIZING;
- ExecInsertIndexTuples(chgcxt->cc_rri,
- chgcxt->cc_estate,
+ ExecInsertIndexTuples(dest->rri,
+ dest->estate,
flags,
spilled_tuple,
NIL, NULL);
@@ -2944,10 +2924,11 @@ adjust_toast_pointers(Relation relation, TupleTableSlot *dest, TupleTableSlot *s
* not found, return false.
*/
static bool
-find_target_tuple(Relation rel, ChangeContext *chgcxt, TupleTableSlot *locator,
+find_target_tuple(RepackDest *dest, TupleTableSlot *locator,
TupleTableSlot *retrieved)
{
- Form_pg_index idx = chgcxt->cc_ident_index->rd_index;
+ Relation rel = dest->rel;
+ Form_pg_index idx = dest->ident_index->rd_index;
IndexScanDesc scan;
bool retval = false;
@@ -2958,9 +2939,9 @@ find_target_tuple(Relation rel, ChangeContext *chgcxt, TupleTableSlot *locator,
*
* Use the incoming tuple to finalize the scan key.
*/
- for (int i = 0; i < chgcxt->cc_ident_key_nentries; i++)
+ for (int i = 0; i < dest->ident_key_nentries; i++)
{
- ScanKey entry = &chgcxt->cc_ident_key[i];
+ ScanKey entry = &dest->ident_key[i];
AttrNumber attno = idx->indkey.values[i];
entry->sk_argument = locator->tts_values[attno - 1];
@@ -2968,13 +2949,13 @@ find_target_tuple(Relation rel, ChangeContext *chgcxt, TupleTableSlot *locator,
}
/* XXX no instrumentation for now */
- scan = index_beginscan(rel, chgcxt->cc_ident_index, GetActiveSnapshot(),
- NULL, chgcxt->cc_ident_key_nentries, 0, 0);
- index_rescan(scan, chgcxt->cc_ident_key, chgcxt->cc_ident_key_nentries, NULL, 0);
+ scan = index_beginscan(rel, dest->ident_index, GetActiveSnapshot(),
+ NULL, dest->ident_key_nentries, 0, 0);
+ index_rescan(scan, dest->ident_key, dest->ident_key_nentries, NULL, 0);
while (index_getnext_slot(scan, ForwardScanDirection, retrieved))
{
/* Be wary of temporal constraints */
- if (scan->xs_recheck && !identity_key_equal(chgcxt, locator, retrieved))
+ if (scan->xs_recheck && !identity_key_equal(dest, locator, retrieved))
{
CHECK_FOR_INTERRUPTS();
continue;
@@ -2997,16 +2978,16 @@ find_target_tuple(Relation rel, ChangeContext *chgcxt, TupleTableSlot *locator,
* used for temporal constraints.
*/
static bool
-identity_key_equal(ChangeContext *chgcxt, TupleTableSlot *locator,
+identity_key_equal(RepackDest *dest, TupleTableSlot *locator,
TupleTableSlot *candidate)
{
- slot_getsomeattrs(locator, chgcxt->cc_last_key_attno);
- slot_getsomeattrs(candidate, chgcxt->cc_last_key_attno);
+ slot_getsomeattrs(locator, dest->last_key_attno);
+ slot_getsomeattrs(candidate, dest->last_key_attno);
- for (int i = 0; i < chgcxt->cc_ident_key_nentries; i++)
+ for (int i = 0; i < dest->ident_key_nentries; i++)
{
- ScanKey entry = &chgcxt->cc_ident_key[i];
- AttrNumber attno = chgcxt->cc_ident_index->rd_index->indkey.values[i];
+ ScanKey entry = &dest->ident_key[i];
+ AttrNumber attno = dest->ident_index->rd_index->indkey.values[i];
Assert(attno > 0);
@@ -3077,7 +3058,7 @@ process_concurrent_changes(XLogRecPtr end_of_wal, ChangeContext *chgcxt, bool do
/* Open the file. */
DecodingWorkerFileName(fname, shared->relid, chgcxt->cc_file_seq);
file = BufFileOpenFileSet(&shared->sfs.fs, fname, O_RDONLY, false);
- apply_concurrent_changes(file, chgcxt);
+ apply_concurrent_changes(chgcxt);
BufFileClose(file);
@@ -3093,41 +3074,65 @@ static void
initialize_change_context(ChangeContext *chgcxt,
Relation relation, Oid ident_index_id)
{
- chgcxt->cc_rel = relation;
+ initialize_change_dest(&chgcxt->cc_dest, relation, ident_index_id);
+
+ chgcxt->cc_file_seq = WORKER_FILE_SNAPSHOT + 1;
+}
+
+/*
+ * Free up resources taken by a ChangeContext.
+ */
+static void
+release_change_context(ChangeContext *chgcxt)
+{
+ release_change_dest(&chgcxt->cc_dest);
+}
+
+/*
+ * Initialize the RepackDest struct for the given relation, with the given
+ * index as identity index. InvalidOid can be specified to only make the
+ * relation ready for insertions.
+ */
+static void
+initialize_change_dest(RepackDest *dest, Relation relation,
+ Oid ident_index_id)
+{
+ dest->rel = relation;
+ dest->bistate = GetBulkInsertState();
/* Only initialize fields needed by ExecInsertIndexTuples(). */
- chgcxt->cc_estate = CreateExecutorState();
+ dest->estate = CreateExecutorState();
- chgcxt->cc_rri = (ResultRelInfo *) palloc(sizeof(ResultRelInfo));
- InitResultRelInfo(chgcxt->cc_rri, relation, 0, 0, 0);
- ExecOpenIndices(chgcxt->cc_rri, false);
+ dest->rri = (ResultRelInfo *) palloc(sizeof(ResultRelInfo));
+ InitResultRelInfo(dest->rri, relation, 0, 0, 0);
+ ExecOpenIndices(dest->rri, false);
/*
* The table's relcache entry already has the relcache entry for the
* identity index; find that.
*/
- chgcxt->cc_ident_index = NULL;
- for (int i = 0; i < chgcxt->cc_rri->ri_NumIndices; i++)
+ dest->ident_index = NULL;
+ for (int i = 0; i < dest->rri->ri_NumIndices; i++)
{
Relation ind_rel;
- ind_rel = chgcxt->cc_rri->ri_IndexRelationDescs[i];
+ ind_rel = dest->rri->ri_IndexRelationDescs[i];
if (ind_rel->rd_id == ident_index_id)
{
- chgcxt->cc_ident_index = ind_rel;
+ dest->ident_index = ind_rel;
break;
}
}
- if (chgcxt->cc_ident_index == NULL)
+ if (dest->ident_index == NULL)
elog(ERROR, "could not find identity index");
/* Set up for scanning said identity index */
{
Form_pg_index indexForm;
- indexForm = chgcxt->cc_ident_index->rd_index;
- chgcxt->cc_ident_key_nentries = indexForm->indnkeyatts;
- chgcxt->cc_ident_key = (ScanKey) palloc_array(ScanKeyData, indexForm->indnkeyatts);
+ indexForm = dest->ident_index->rd_index;
+ dest->ident_key_nentries = indexForm->indnkeyatts;
+ dest->ident_key = (ScanKey) palloc_array(ScanKeyData, indexForm->indnkeyatts);
for (int i = 0; i < indexForm->indnkeyatts; i++)
{
ScanKey entry;
@@ -3137,12 +3142,12 @@ initialize_change_context(ChangeContext *chgcxt,
opcode;
StrategyNumber eq_strategy;
- entry = &chgcxt->cc_ident_key[i];
+ entry = &dest->ident_key[i];
- opfamily = chgcxt->cc_ident_index->rd_opfamily[i];
- opcintype = chgcxt->cc_ident_index->rd_opcintype[i];
+ opfamily = dest->ident_index->rd_opfamily[i];
+ opcintype = dest->ident_index->rd_opcintype[i];
eq_strategy = IndexAmTranslateCompareType(COMPARE_EQ,
- chgcxt->cc_ident_index->rd_rel->relam,
+ dest->ident_index->rd_rel->relam,
opfamily, false);
if (eq_strategy == InvalidStrategy)
elog(ERROR, "could not find equality strategy for index operator family %u for type %u",
@@ -3161,34 +3166,30 @@ initialize_change_context(ChangeContext *chgcxt,
i + 1,
eq_strategy, opcode,
(Datum) 0);
- entry->sk_collation = chgcxt->cc_ident_index->rd_indcollation[i];
+ entry->sk_collation = dest->ident_index->rd_indcollation[i];
}
}
/* Determine the last column we must deform to read the identity */
- chgcxt->cc_last_key_attno = InvalidAttrNumber;
- for (int i = 0; i < chgcxt->cc_ident_key_nentries; i++)
+ dest->last_key_attno = InvalidAttrNumber;
+ for (int i = 0; i < dest->ident_key_nentries; i++)
{
- AttrNumber attno = chgcxt->cc_ident_index->rd_index->indkey.values[i];
+ AttrNumber attno = dest->ident_index->rd_index->indkey.values[i];
Assert(attno > 0);
- chgcxt->cc_last_key_attno = Max(chgcxt->cc_last_key_attno, attno);
+ dest->last_key_attno = Max(dest->last_key_attno, attno);
}
-
- chgcxt->cc_file_seq = WORKER_FILE_SNAPSHOT + 1;
}
-/*
- * Free up resources taken by a ChangeContext.
- */
static void
-release_change_context(ChangeContext *chgcxt)
+release_change_dest(RepackDest *dest)
{
- ExecCloseIndices(chgcxt->cc_rri);
- FreeExecutorState(chgcxt->cc_estate);
+ FreeBulkInsertState(dest->bistate);
+ ExecCloseIndices(dest->rri);
+ FreeExecutorState(dest->estate);
/* XXX are these pfrees necessary? */
- pfree(chgcxt->cc_rri);
- pfree(chgcxt->cc_ident_key);
+ pfree(dest->rri);
+ pfree(dest->ident_key);
}
/*
diff --git a/src/include/commands/repack.h b/src/include/commands/repack.h
index 27105c10591..07f887e99f6 100644
--- a/src/include/commands/repack.h
+++ b/src/include/commands/repack.h
@@ -16,6 +16,7 @@
#include <signal.h>
#include "access/hio.h"
+#include "access/skey.h"
#include "nodes/execnodes.h"
#include "nodes/parsenodes.h"
#include "parser/parse_node.h"
@@ -39,6 +40,53 @@ typedef struct ClusterParams
extern PGDLLIMPORT volatile sig_atomic_t RepackMessagePending;
+/*
+ * Table to apply concurrent data changes to.
+ */
+typedef struct RepackDest
+{
+ /* The relation the changes are applied to. */
+ Relation rel;
+
+ BulkInsertStateData *bistate;
+
+ /* Needed to update indexes of cc_rel. */
+ ResultRelInfo *rri;
+ EState *estate;
+
+ /*
+ * Existing tuples to UPDATE and DELETE are located via this index. We
+ * keep the scankey in partially initialized state to avoid repeated work.
+ * sk_argument is completed on the fly.
+ */
+ Relation ident_index;
+ ScanKey ident_key;
+
+ int ident_key_nentries;
+
+ /* The latest column we need to deform to have the tuple identity */
+ AttrNumber last_key_attno;
+} RepackDest;
+
+/*
+ * The first file exported by the decoding worker must contain a snapshot, the
+ * following ones contain the data changes.
+ */
+#define WORKER_FILE_SNAPSHOT 0
+
+/*
+ * Information needed to apply concurrent data changes.
+ *
+ * XXX Now that it's in *.h file, rename to RepackChangeContext?
+ */
+typedef struct ChangeContext
+{
+ /* The destination table. */
+ RepackDest cc_dest;
+
+ /* Sequential number of the file containing the changes. */
+ int cc_file_seq;
+} ChangeContext;
extern void ExecRepack(ParseState *pstate, RepackStmt *stmt, bool isTopLevel);
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index f9eb23e52c9..b4d5abbaca7 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -2660,6 +2660,7 @@ ReorderBufferTupleCidKey
ReorderBufferUpdateProgressTxnCB
ReorderTuple
RepackCommand
+RepackDest
RepackDecodingState
RepackStmt
ReparameterizeForeignPathByChild_function
--
2.52.0
--=-=-=
Content-Type: text/plain
Content-Disposition: attachment;
filename=v01-0004-Use-multiple-snapshots-to-copy-the-data.patch
^ permalink raw reply [nested|flat] 21+ messages in thread
end of thread, other threads:[~2026-06-16 11:54 UTC | newest]
Thread overview: 21+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-22 17:47 BUG #3774: create table like including index doesn't update pg_constraints with primary key guillaume (ioguix) de Rorthais <ioguix@free.fr>
2007-11-30 07:44 ` NikhilS <nikkhils@gmail.com>
2007-12-01 23:46 ` Tom Lane <tgl@sss.pgh.pa.us>
2007-12-02 08:14 ` NikhilS <nikkhils@gmail.com>
2007-12-13 00:34 ` Bruce Momjian <bruce@momjian.us>
2008-03-06 21:45 ` Bruce Momjian <bruce@momjian.us>
2008-03-06 22:20 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-03-17 18:16 [PATCH v15 03/10] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v30 02/11] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v28 02/11] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v31 02/11] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v24 03/11] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v20 03/10] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v15 03/10] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v30 02/11] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v25 03/11] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v21 03/10] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v22 03/10] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v19 03/10] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2020-03-17 18:16 [PATCH v31 02/11] Add tests on pg_ls_dir before changing it Justin Pryzby <pryzbyj@telsasoft.com>
2026-06-16 11:54 [PATCH 3/8] Introduce RepackDest structure. Antonin Houska <ah@cybertec.at>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox