agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
BUG #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 2/5] Refactor index_concurrently_create_copy() for use with REPACK (CONCURRENTLY).
@ 2026-02-16 19:49  Antonin Houska <ah@cybertec.at>
  0 siblings, 0 replies; 21+ messages in thread

From: Antonin Houska @ 2026-02-16 19:49 UTC (permalink / raw)

This patch moves the code to index_create_copy() and adds a "concurrently"
parameter so it can be used by REPACK (CONCURRENTLY).

With the CONCURRENTLY option, REPACK cannot simply swap the heap file and
rebuild its indexes. Instead, it needs to build a separate set of indexes
(including system catalog entries) *before* the actual swap, to reduce the
time AccessExclusiveLock needs to be held for.
---
 src/backend/catalog/index.c      | 54 +++++++++++++++++++++++---------
 src/backend/commands/indexcmds.c |  6 ++--
 src/backend/nodes/makefuncs.c    |  9 +++---
 src/include/catalog/index.h      |  3 ++
 src/include/nodes/makefuncs.h    |  4 ++-
 5 files changed, 54 insertions(+), 22 deletions(-)

diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 5ee6389d39c..f8e6c3d804e 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -1288,15 +1288,32 @@ index_create(Relation heapRelation,
 /*
  * index_concurrently_create_copy
  *
- * Create concurrently an index based on the definition of the one provided by
- * caller.  The index is inserted into catalogs and needs to be built later
- * on.  This is called during concurrent reindex processing.
- *
- * "tablespaceOid" is the tablespace to use for this index.
+ * Variant of index_create_copy(), called during concurrent reindex
+ * processing.
  */
 Oid
 index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
 							   Oid tablespaceOid, const char *newName)
+{
+	return index_create_copy(heapRelation, oldIndexId, tablespaceOid, newName,
+							 true);
+}
+
+/*
+ * index_create_copy
+ *
+ * Create an index based on the definition of the one provided by caller.  The
+ * index is inserted into catalogs. If 'concurrently' is TRUE, it needs to be
+ * built later on, otherwise it's built immediately.
+ *
+ * "tablespaceOid" is the tablespace to use for this index.
+ *
+ * The actual implementation of index_concurrently_create_copy(), reusable for
+ * other purposes.
+ */
+Oid
+index_create_copy(Relation heapRelation, Oid oldIndexId, Oid tablespaceOid,
+				  const char *newName, bool concurrently)
 {
 	Relation	indexRelation;
 	IndexInfo  *oldInfo,
@@ -1315,6 +1332,7 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
 	List	   *indexColNames = NIL;
 	List	   *indexExprs = NIL;
 	List	   *indexPreds = NIL;
+	int			flags = 0;
 
 	indexRelation = index_open(oldIndexId, RowExclusiveLock);
 
@@ -1325,7 +1343,7 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
 	 * Concurrent build of an index with exclusion constraints is not
 	 * supported.
 	 */
-	if (oldInfo->ii_ExclusionOps != NULL)
+	if (oldInfo->ii_ExclusionOps != NULL && concurrently)
 		ereport(ERROR,
 				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
 				 errmsg("concurrent index creation for exclusion constraints is not supported")));
@@ -1381,9 +1399,7 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
 	}
 
 	/*
-	 * Build the index information for the new index.  Note that rebuild of
-	 * indexes with exclusion constraints is not supported, hence there is no
-	 * need to fill all the ii_Exclusion* fields.
+	 * Build the index information for the new index.
 	 */
 	newInfo = makeIndexInfo(oldInfo->ii_NumIndexAttrs,
 							oldInfo->ii_NumIndexKeyAttrs,
@@ -1392,10 +1408,13 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
 							indexPreds,
 							oldInfo->ii_Unique,
 							oldInfo->ii_NullsNotDistinct,
-							false,	/* not ready for inserts */
-							true,
+							!concurrently,	/* isready */
+							concurrently,	/* concurrent */
 							indexRelation->rd_indam->amsummarizing,
-							oldInfo->ii_WithoutOverlaps);
+							oldInfo->ii_WithoutOverlaps,
+							oldInfo->ii_ExclusionOps,
+							oldInfo->ii_ExclusionProcs,
+							oldInfo->ii_ExclusionStrats);
 
 	/*
 	 * Extract the list of column names and the column numbers for the new
@@ -1433,6 +1452,9 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
 		stattargets[i].isnull = isnull;
 	}
 
+	if (concurrently)
+		flags = INDEX_CREATE_SKIP_BUILD | INDEX_CREATE_CONCURRENT;
+
 	/*
 	 * Now create the new index.
 	 *
@@ -1456,7 +1478,7 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
 							  indcoloptions->values,
 							  stattargets,
 							  reloptionsDatum,
-							  INDEX_CREATE_SKIP_BUILD | INDEX_CREATE_CONCURRENT,
+							  flags,
 							  0,
 							  true, /* allow table to be a system catalog? */
 							  false,	/* is_internal? */
@@ -2450,7 +2472,8 @@ BuildIndexInfo(Relation index)
 					   indexStruct->indisready,
 					   false,
 					   index->rd_indam->amsummarizing,
-					   indexStruct->indisexclusion && indexStruct->indisunique);
+					   indexStruct->indisexclusion && indexStruct->indisunique,
+					   NULL, NULL, NULL);
 
 	/* fill in attribute numbers */
 	for (i = 0; i < numAtts; i++)
@@ -2510,7 +2533,8 @@ BuildDummyIndexInfo(Relation index)
 					   indexStruct->indisready,
 					   false,
 					   index->rd_indam->amsummarizing,
-					   indexStruct->indisexclusion && indexStruct->indisunique);
+					   indexStruct->indisexclusion && indexStruct->indisunique,
+					   NULL, NULL, NULL);
 
 	/* fill in attribute numbers */
 	for (i = 0; i < numAtts; i++)
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 635679cc1f2..34209bd1393 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -243,7 +243,8 @@ CheckIndexCompatible(Oid oldId,
 	 */
 	indexInfo = makeIndexInfo(numberOfAttributes, numberOfAttributes,
 							  accessMethodId, NIL, NIL, false, false,
-							  false, false, amsummarizing, isWithoutOverlaps);
+							  false, false, amsummarizing, isWithoutOverlaps,
+							  NULL, NULL, NULL);
 	typeIds = palloc_array(Oid, numberOfAttributes);
 	collationIds = palloc_array(Oid, numberOfAttributes);
 	opclassIds = palloc_array(Oid, numberOfAttributes);
@@ -930,7 +931,8 @@ DefineIndex(ParseState *pstate,
 							  !concurrent,
 							  concurrent,
 							  amissummarizing,
-							  stmt->iswithoutoverlaps);
+							  stmt->iswithoutoverlaps,
+							  NULL, NULL, NULL);
 
 	typeIds = palloc_array(Oid, numberOfAttributes);
 	collationIds = palloc_array(Oid, numberOfAttributes);
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c
index 2caec621d73..ca7e21e8349 100644
--- a/src/backend/nodes/makefuncs.c
+++ b/src/backend/nodes/makefuncs.c
@@ -834,7 +834,8 @@ IndexInfo *
 makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid, List *expressions,
 			  List *predicates, bool unique, bool nulls_not_distinct,
 			  bool isready, bool concurrent, bool summarizing,
-			  bool withoutoverlaps)
+			  bool withoutoverlaps, Oid *exclusion_ops, Oid *exclusion_procs,
+			  uint16 *exclusion_strats)
 {
 	IndexInfo  *n = makeNode(IndexInfo);
 
@@ -863,9 +864,9 @@ makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid, List *expressions,
 	n->ii_PredicateState = NULL;
 
 	/* exclusion constraints */
-	n->ii_ExclusionOps = NULL;
-	n->ii_ExclusionProcs = NULL;
-	n->ii_ExclusionStrats = NULL;
+	n->ii_ExclusionOps = exclusion_ops;
+	n->ii_ExclusionProcs = exclusion_procs;
+	n->ii_ExclusionStrats = exclusion_strats;
 
 	/* speculative inserts */
 	n->ii_UniqueOps = NULL;
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index b259c4141ed..3426087b445 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -99,6 +99,9 @@ extern Oid	index_concurrently_create_copy(Relation heapRelation,
 										   Oid oldIndexId,
 										   Oid tablespaceOid,
 										   const char *newName);
+extern Oid	index_create_copy(Relation heapRelation, Oid oldIndexId,
+							  Oid tablespaceOid, const char *newName,
+							  bool concurrently);
 
 extern void index_concurrently_build(Oid heapRelationId,
 									 Oid indexRelationId);
diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h
index 982ec25ae14..dcea148ae1a 100644
--- a/src/include/nodes/makefuncs.h
+++ b/src/include/nodes/makefuncs.h
@@ -99,7 +99,9 @@ extern IndexInfo *makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid,
 								List *expressions, List *predicates,
 								bool unique, bool nulls_not_distinct,
 								bool isready, bool concurrent,
-								bool summarizing, bool withoutoverlaps);
+								bool summarizing, bool withoutoverlaps,
+								Oid *exclusion_ops, Oid *exclusion_procs,
+								uint16 *exclusion_strats);
 
 extern Node *makeStringConst(char *str, int location);
 extern DefElem *makeDefElem(char *name, Node *arg, int location);
-- 
2.47.3


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=v34-0003-Move-conversion-of-a-historic-to-MVCC-snapshot-to-a-.patch



^ permalink  raw  reply  [nested|flat] 21+ messages in thread


end of thread, other threads:[~2026-02-16 19:49 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 v28 02/11] 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 v24 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 v30 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 v22 03/10] 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 v19 03/10] 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 v15 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-02-16 19:49 [PATCH 2/5] Refactor index_concurrently_create_copy() for use with REPACK (CONCURRENTLY). 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