Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hgvpt-0002MM-V3 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Jun 2019 18:43:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hgvpr-0001L4-Q2 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Jun 2019 18:42:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hgvpr-0001Eh-4l for pgsql-hackers@lists.postgresql.org; Fri, 28 Jun 2019 18:42:59 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hgvpl-0004LE-IR for pgsql-hackers@postgresql.org; Fri, 28 Jun 2019 18:42:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x5SIgn9g003607; Fri, 28 Jun 2019 14:42:49 -0400 From: Tom Lane To: Stephen Frost cc: Robert Haas , Alvaro Herrera , "pgsql-hackers@postgresql.org" Subject: Re: [HACKERS] Regression tests vs existing users in an installation In-reply-to: <20190628154110.GM2480@tamriel.snowman.net> References: <20160716035456.GA181422@alvherre.pgsql> <25245.1468683514@sss.pgh.pa.us> <23690.1468854782@sss.pgh.pa.us> <1382.1561520002@sss.pgh.pa.us> <27282.1561668606@sss.pgh.pa.us> <20190628154110.GM2480@tamriel.snowman.net> Comments: In-reply-to Stephen Frost message dated "Fri, 28 Jun 2019 11:41:11 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <3550.1561747315.0@sss.pgh.pa.us> Date: Fri, 28 Jun 2019 14:42:49 -0400 Message-ID: <3606.1561747369@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3550.1561747315.1@sss.pgh.pa.us> OK, here's a completed patch to add checking for naming-rule violations. I updated regress.sgml to clarify the naming rules (and failed to resist the temptation to update a lot of other somewhat-obsolete statements there, too). Also worth noting is that I added an IsReservedName check to pg_replication_origin_create(), ie it will no longer allow user-selected origin names starting with "pg_". This seems like a good idea considering that we generate internal origin names that look like that. I have not done anything equivalent for subscription names, but should we consider doing so? I touched the TAP tests only to the extent necessary to make them pass cleanly --- mostly I had to fool with pg_dump/t/010_dump_connstr.pl because it whines if the restore step emits any warnings. Perhaps there's another way to address that with less invasive changes to that test script; but I couldn't think of one other than ignoring warnings, which didn't seem like a great idea. This patch doesn't address the issue that we think rolenames.sql is unsafe to run in "make installcheck" mode. That seems like a separable problem, and we'd have to adjust that script as shown here anyway. Barring objections, I'll push this shortly (to HEAD only) and turn on the enabling switch on one or two of my buildfarm critters. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="0001-code-and-doc-fixes.patch"; charset="us-ascii" Content-ID: <3550.1561747315.2@sss.pgh.pa.us> Content-Description: 0001-code-and-doc-fixes.patch Content-Transfer-Encoding: quoted-printable diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml index 448e2d1..7b68213 100644 --- a/doc/src/sgml/regress.sgml +++ b/doc/src/sgml/regress.sgml @@ -47,7 +47,7 @@ make check =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - All 115 tests passed. + All 193 tests passed. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @@ -98,7 +98,7 @@ make MAX_CONNECTIONS=3D10 check = To run the tests after installation (see ), - initialize a data area and start the + initialize a data directory and start the server as explained in , then type: make installcheck @@ -116,10 +116,10 @@ make installcheck-parallel = The tests will also transiently create some cluster-wide objects, such= as - roles and tablespaces. These objects will have names beginning with - regress_. Beware of using installcheck - mode in installations that have any actual users or tablespaces named - that way. + roles, tablespaces, and subscriptions. These objects will have names + beginning with regress_. Beware of + using installcheck mode with an installation that h= as + any actual global objects named that way. = @@ -130,7 +130,7 @@ make installcheck-parallel The make check and make installcheck commands run only the core regression tests, which test built-in functionality of the PostgreSQL server. Th= e source - distribution also contains additional test suites, most of them having + distribution contains many additional test suites, most of them having to do with add-on functionality such as optional procedural languages. = @@ -146,9 +146,24 @@ make installcheck-world already-installed server, respectively, just as previously explained for make check and make installcheck. Other considerations are the same as previously explained for each method. - Note that make check-world builds a separate tempor= ary - installation tree for each tested module, so it requires a great deal - more time and disk space than make installcheck-world. + Note that make check-world builds a separate instan= ce + (temporary data directory) for each tested module, so it requires more + time and disk space than make installcheck-world. + + + + On a modern machine with multiple CPU cores and no tight operating-sys= tem + limits, you can make things go substantially faster with parallelism. + The recipe that most PostgreSQL developers actually use for running al= l + tests is something like + +make check-world -j8 >/dev/null + + with a limit near to or a bit more than the number + of available cores. Discarding stdout + eliminates chatter that's not interesting when you just want to verify + success. (In case of failure, the stderr + messages are usually enough to determine where to look closer.) = @@ -166,8 +181,7 @@ make installcheck-world - Regression tests for optional procedural languages (other than - PL/pgSQL, which is tested by the core tes= ts). + Regression tests for optional procedural languages. These are located under src/pl. @@ -186,27 +200,49 @@ make installcheck-world + Tests for core-supported authentication methods, + located in src/test/authentication. + (See below for additional authentication-related tests.) + + + + Tests stressing behavior of concurrent sessions, located in src/test/isolation. - Tests of client programs under src/bin. See - also . + Tests for crash recovery and physical replication, + located in src/test/recovery. + + + + + Tests for logical replication, + located in src/test/subscription. + + + + + Tests of client programs, located under src/bin= . = - When using installcheck mode, these tests will dest= roy any - existing databases named pl_regression, - contrib_regression, isolation_regression, - ecpg1_regression, or ecpg2_regression, as well as - regression. + When using installcheck mode, these tests will crea= te + and destroy test databases whose names + include regression, for + example pl_regression + or contrib_regression. Beware of + using installcheck mode with an installation that h= as + any non-test databases named that way. = + Some of these auxiliary test suites use the TAP infrastructure explain= ed + in . The TAP-based tests are run only when PostgreSQL was configured with t= he option . This is recommended for development, but can be omitted if there is no suitable Perl installat= ion. @@ -259,6 +295,17 @@ make check-world PG_TEST_EXTRA=3D'kerberos ldap ssl' configuration are not run even if they are mentioned in PG_TEST_EXTRA. + + + In addition, there are tests in src/test/modules + which will be run by make check-world but not + by make installcheck-world. This is because they + install non-production extensions or have other side-effects that are + considered undesirable for a production installation. You can + use make install and make + installcheck in one of those subdirectories if you wish, + but it's not recommended to do so with a non-test server. + = @@ -737,6 +784,26 @@ make check PROVE_TESTS=3D't/001_test1.pl t/003_test3.= pl' The TAP tests require the Perl module IPC::Run. This module is available from CPAN or an operating system package. + + + Generically speaking, the TAP tests will test the executables in a + previously-installed installation tree if you say make + installcheck, or will build a new local installation tree f= rom + current sources if you say make check. In either + case they will initialize a local instance (data directory) and + transiently run a server in it. Some of these tests run more than on= e + server. Thus, these tests can be fairly resource-intensive. + + + + It's important to realize that the TAP tests will start test server(s= ) + even when you say make installcheck; this is unlik= e + the traditional non-TAP testing infrastructure, which expects to use = an + already-running test server in that case. Some PostgreSQL + subdirectories contain both traditional-style and TAP-style tests, + meaning that make installcheck will produce a mix = of + results from temporary servers and the already-running test server. + = diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index 9229fe1..70dbcb0 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -274,6 +274,12 @@ AlterObjectRename_internal(Relation rel, Oid objectId= , const char *new_name) if (SearchSysCacheExists2(SUBSCRIPTIONNAME, MyDatabaseId, CStringGetDatum(new_name))) report_name_conflict(classId, new_name); + + /* Also enforce regression testing naming rules, if enabled */ +#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS + if (strncmp(new_name, "regress_", 8) !=3D 0) + elog(WARNING, "subscriptions created by regression test cases should h= ave names starting with \"regress_\""); +#endif } else if (nameCacheId >=3D 0) { diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbco= mmands.c index 15207bf..863f89f 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -471,6 +471,16 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt= ) } = /* + * If built with appropriate switch, whine when regression-testing + * conventions for database names are violated. But don't complain duri= ng + * initdb. + */ +#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS + if (IsUnderPostmaster && strstr(dbname, "regression") =3D=3D NULL) + elog(WARNING, "databases created by regression test cases should have n= ames including \"regression\""); +#endif + + /* * Check for db name conflict. This is just to give a more friendly err= or * message than "unique index violation". There's a race condition but * we're willing to accept the less friendly message in that case. @@ -1009,6 +1019,15 @@ RenameDatabase(const char *oldname, const char *new= name) errmsg("permission denied to rename database"))); = /* + * If built with appropriate switch, whine when regression-testing + * conventions for database names are violated. + */ +#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS + if (strstr(newname, "regression") =3D=3D NULL) + elog(WARNING, "databases created by regression test cases should have n= ames including \"regression\""); +#endif + + /* * Make sure the new name doesn't exist. See notes for same error in * CREATE DATABASE. */ diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/command= s/subscriptioncmds.c index f13dce9..2e67a58 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -357,6 +357,15 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool= isTopLevel) (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("must be superuser to create subscriptions")))); = + /* + * If built with appropriate switch, whine when regression-testing + * conventions for subscription names are violated. + */ +#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS + if (strncmp(stmt->subname, "regress_", 8) !=3D 0) + elog(WARNING, "subscriptions created by regression test cases should ha= ve names starting with \"regress_\""); +#endif + rel =3D table_open(SubscriptionRelationId, RowExclusiveLock); = /* Check if name is used */ diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tabl= espace.c index 5e43867..502736b 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -308,6 +308,15 @@ CreateTableSpace(CreateTableSpaceStmt *stmt) errdetail("The prefix \"pg_\" is reserved for system tablespaces."))= ); = /* + * If built with appropriate switch, whine when regression-testing + * conventions for tablespace names are violated. + */ +#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS + if (strncmp(stmt->tablespacename, "regress_", 8) !=3D 0) + elog(WARNING, "tablespaces created by regression test cases should have= names starting with \"regress_\""); +#endif + + /* * Check that there is no other tablespace by this name. (The unique * index would catch this anyway, but might as well give a friendlier * message.) @@ -957,6 +966,15 @@ RenameTableSpace(const char *oldname, const char *new= name) errmsg("unacceptable tablespace name \"%s\"", newname), errdetail("The prefix \"pg_\" is reserved for system tablespaces."))= ); = + /* + * If built with appropriate switch, whine when regression-testing + * conventions for tablespace names are violated. + */ +#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS + if (strncmp(newname, "regress_", 8) !=3D 0) + elog(WARNING, "tablespaces created by regression test cases should have= names starting with \"regress_\""); +#endif + /* Make sure the new name doesn't exist */ ScanKeyInit(&entry[0], Anum_pg_tablespace_spcname, diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index ccc586d..aab5aa8 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -327,6 +327,15 @@ CreateRole(ParseState *pstate, CreateRoleStmt *stmt) errdetail("Role names starting with \"pg_\" are reserved."))); = /* + * If built with appropriate switch, whine when regression-testing + * conventions for role names are violated. + */ +#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS + if (strncmp(stmt->role, "regress_", 8) !=3D 0) + elog(WARNING, "roles created by regression test cases should have names= starting with \"regress_\""); +#endif + + /* * Check the pg_authid relation to be certain the role doesn't already * exist. */ @@ -1212,6 +1221,15 @@ RenameRole(const char *oldname, const char *newname= ) newname), errdetail("Role names starting with \"pg_\" are reserved."))); = + /* + * If built with appropriate switch, whine when regression-testing + * conventions for role names are violated. + */ +#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS + if (strncmp(newname, "regress_", 8) !=3D 0) + elog(WARNING, "roles created by regression test cases should have names= starting with \"regress_\""); +#endif + /* make sure the new name doesn't exist */ if (SearchSysCacheExists1(AUTHNAME, CStringGetDatum(newname))) ereport(ERROR, diff --git a/src/backend/replication/logical/origin.c b/src/backend/replic= ation/logical/origin.c index ff4d54d..681132c 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -78,6 +78,7 @@ #include "access/table.h" #include "access/xact.h" = +#include "catalog/catalog.h" #include "catalog/indexing.h" #include "nodes/execnodes.h" = @@ -1228,6 +1229,24 @@ pg_replication_origin_create(PG_FUNCTION_ARGS) replorigin_check_prerequisites(false, false); = name =3D text_to_cstring((text *) DatumGetPointer(PG_GETARG_DATUM(0))); + + /* Replication origins "pg_xxx" are reserved for internal use */ + if (IsReservedName(name)) + ereport(ERROR, + (errcode(ERRCODE_RESERVED_NAME), + errmsg("replication origin name \"%s\" is reserved", + name), + errdetail("Origin names starting with \"pg_\" are reserved."))); + + /* + * If built with appropriate switch, whine when regression-testing + * conventions for replication origin names are violated. + */ +#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS + if (strncmp(name, "regress_", 8) !=3D 0) + elog(WARNING, "replication origins created by regression test cases sho= uld have names starting with \"regress_\""); +#endif + roident =3D replorigin_create(name); = pfree(name); diff --git a/src/test/modules/README b/src/test/modules/README index 99f921d..025ecac 100644 --- a/src/test/modules/README +++ b/src/test/modules/README @@ -6,6 +6,13 @@ intended for testing PostgreSQL and/or to serve as exampl= e code. The extensions here aren't intended to be installed in a production server and aren't su= itable for "real work". = +Furthermore, while you can do "make install" and "make installcheck" in +this directory or its children, it is NOT ADVISABLE to do so with a serve= r +containing valuable data. Some of these tests may have undesirable +side-effects on roles or other global objects within the tested server. +"make installcheck-world" at the top level does not recurse into this +directory. + Most extensions have their own pg_regress tests or isolationtester specs.= Some are also used by tests elsewhere in the tree. = ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="0002-clean-up-test-cases.patch"; charset="us-ascii" Content-ID: <3550.1561747315.3@sss.pgh.pa.us> Content-Description: 0002-clean-up-test-cases.patch Content-Transfer-Encoding: quoted-printable diff --git a/contrib/test_decoding/expected/replorigin.out b/contrib/test_= decoding/expected/replorigin.out index 8ea4ddd..3b249f4 100644 --- a/contrib/test_decoding/expected/replorigin.out +++ b/contrib/test_decoding/expected/replorigin.out @@ -2,38 +2,38 @@ SET synchronous_commit =3D on; CREATE TABLE origin_tbl(id serial primary key, data text); CREATE TABLE target_tbl(id serial primary key, data text); -SELECT pg_replication_origin_create('test_decoding: regression_slot'); +SELECT pg_replication_origin_create('regress_test_decoding: regression_sl= ot'); pg_replication_origin_create = ------------------------------ 1 (1 row) = -- ensure duplicate creations fail -SELECT pg_replication_origin_create('test_decoding: regression_slot'); +SELECT pg_replication_origin_create('regress_test_decoding: regression_sl= ot'); ERROR: duplicate key value violates unique constraint "pg_replication_or= igin_roname_index" -DETAIL: Key (roname)=3D(test_decoding: regression_slot) already exists. +DETAIL: Key (roname)=3D(regress_test_decoding: regression_slot) already = exists. --ensure deletions work (once) -SELECT pg_replication_origin_create('test_decoding: temp'); +SELECT pg_replication_origin_create('regress_test_decoding: temp'); pg_replication_origin_create = ------------------------------ 2 (1 row) = -SELECT pg_replication_origin_drop('test_decoding: temp'); +SELECT pg_replication_origin_drop('regress_test_decoding: temp'); pg_replication_origin_drop = ---------------------------- = (1 row) = -SELECT pg_replication_origin_drop('test_decoding: temp'); -ERROR: replication origin "test_decoding: temp" does not exist +SELECT pg_replication_origin_drop('regress_test_decoding: temp'); +ERROR: replication origin "regress_test_decoding: temp" does not exist -- various failure checks for undefined slots -select pg_replication_origin_advance('test_decoding: temp', '0/1'); -ERROR: replication origin "test_decoding: temp" does not exist -select pg_replication_origin_session_setup('test_decoding: temp'); -ERROR: replication origin "test_decoding: temp" does not exist -select pg_replication_origin_progress('test_decoding: temp', true); -ERROR: replication origin "test_decoding: temp" does not exist +select pg_replication_origin_advance('regress_test_decoding: temp', '0/1'= ); +ERROR: replication origin "regress_test_decoding: temp" does not exist +select pg_replication_origin_session_setup('regress_test_decoding: temp')= ; +ERROR: replication origin "regress_test_decoding: temp" does not exist +select pg_replication_origin_progress('regress_test_decoding: temp', true= ); +ERROR: replication origin "regress_test_decoding: temp" does not exist SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', = 'test_decoding'); ?column? = ---------- @@ -57,14 +57,14 @@ SELECT data FROM pg_logical_slot_get_changes('regressi= on_slot', NULL, NULL, 'inc = INSERT INTO origin_tbl(data) VALUES ('will be replicated, but not decoded= again'); -- mark session as replaying -SELECT pg_replication_origin_session_setup('test_decoding: regression_slo= t'); +SELECT pg_replication_origin_session_setup('regress_test_decoding: regres= sion_slot'); pg_replication_origin_session_setup = ------------------------------------- = (1 row) = -- ensure we prevent duplicate setup -SELECT pg_replication_origin_session_setup('test_decoding: regression_slo= t'); +SELECT pg_replication_origin_session_setup('regress_test_decoding: regres= sion_slot'); ERROR: cannot setup replication origin when one is already setup SELECT '' FROM pg_logical_emit_message(false, 'test', 'this message will = not be decoded'); ?column? = @@ -103,19 +103,19 @@ SELECT pg_replication_origin_session_reset(); (1 row) = SELECT local_id, external_id, remote_lsn, local_lsn <> '0/0' FROM pg_repl= ication_origin_status; - local_id | external_id | remote_lsn | ?column? = -----------+--------------------------------+------------+---------- - 1 | test_decoding: regression_slot | 0/AABBCCDD | t + local_id | external_id | remote_lsn | ?column= ? = +----------+----------------------------------------+------------+--------= -- + 1 | regress_test_decoding: regression_slot | 0/AABBCCDD | t (1 row) = -- check replication progress identified by name is correct -SELECT pg_replication_origin_progress('test_decoding: regression_slot', f= alse); +SELECT pg_replication_origin_progress('regress_test_decoding: regression_= slot', false); pg_replication_origin_progress = -------------------------------- 0/AABBCCDD (1 row) = -SELECT pg_replication_origin_progress('test_decoding: regression_slot', t= rue); +SELECT pg_replication_origin_progress('regress_test_decoding: regression_= slot', true); pg_replication_origin_progress = -------------------------------- 0/AABBCCDD @@ -146,7 +146,7 @@ SELECT pg_drop_replication_slot('regression_slot'); = (1 row) = -SELECT pg_replication_origin_drop('test_decoding: regression_slot'); +SELECT pg_replication_origin_drop('regress_test_decoding: regression_slot= '); pg_replication_origin_drop = ---------------------------- = diff --git a/contrib/test_decoding/expected/rewrite.out b/contrib/test_dec= oding/expected/rewrite.out index 28998b8..b30999c 100644 --- a/contrib/test_decoding/expected/rewrite.out +++ b/contrib/test_decoding/expected/rewrite.out @@ -11,7 +11,7 @@ CREATE FUNCTION exec(text) returns void language plpgsql= volatile EXECUTE $1; END; $f$; -CREATE ROLE justforcomments NOLOGIN; +CREATE ROLE regress_justforcomments NOLOGIN; SELECT exec( format($outer$CREATE FUNCTION iamalongfunction() RETURNS TEXT IMMUTAB= LE LANGUAGE SQL AS $f$SELECT text %L$f$$outer$, (SELECT repeat(string_agg(to_char(g.i, 'FM0000'), ''), 50) FRO= M generate_series(1, 500) g(i)))); @@ -29,7 +29,7 @@ SELECT exec( (1 row) = SELECT exec( - format($outer$COMMENT ON ROLE JUSTFORCOMMENTS IS %L$outer$, + format($outer$COMMENT ON ROLE REGRESS_JUSTFORCOMMENTS IS %L$outer$, iamalongfunction())); exec = ------ @@ -161,4 +161,4 @@ SELECT pg_drop_replication_slot('regression_slot'); DROP TABLE IF EXISTS replication_example; DROP FUNCTION iamalongfunction(); DROP FUNCTION exec(text); -DROP ROLE justforcomments; +DROP ROLE regress_justforcomments; diff --git a/contrib/test_decoding/sql/replorigin.sql b/contrib/test_decod= ing/sql/replorigin.sql index 451cd4b..8979b30 100644 --- a/contrib/test_decoding/sql/replorigin.sql +++ b/contrib/test_decoding/sql/replorigin.sql @@ -4,19 +4,19 @@ SET synchronous_commit =3D on; CREATE TABLE origin_tbl(id serial primary key, data text); CREATE TABLE target_tbl(id serial primary key, data text); = -SELECT pg_replication_origin_create('test_decoding: regression_slot'); +SELECT pg_replication_origin_create('regress_test_decoding: regression_sl= ot'); -- ensure duplicate creations fail -SELECT pg_replication_origin_create('test_decoding: regression_slot'); +SELECT pg_replication_origin_create('regress_test_decoding: regression_sl= ot'); = --ensure deletions work (once) -SELECT pg_replication_origin_create('test_decoding: temp'); -SELECT pg_replication_origin_drop('test_decoding: temp'); -SELECT pg_replication_origin_drop('test_decoding: temp'); +SELECT pg_replication_origin_create('regress_test_decoding: temp'); +SELECT pg_replication_origin_drop('regress_test_decoding: temp'); +SELECT pg_replication_origin_drop('regress_test_decoding: temp'); = -- various failure checks for undefined slots -select pg_replication_origin_advance('test_decoding: temp', '0/1'); -select pg_replication_origin_session_setup('test_decoding: temp'); -select pg_replication_origin_progress('test_decoding: temp', true); +select pg_replication_origin_advance('regress_test_decoding: temp', '0/1'= ); +select pg_replication_origin_session_setup('regress_test_decoding: temp')= ; +select pg_replication_origin_progress('regress_test_decoding: temp', true= ); = SELECT 'init' FROM pg_create_logical_replication_slot('regression_slot', = 'test_decoding'); = @@ -31,10 +31,10 @@ SELECT data FROM pg_logical_slot_get_changes('regressi= on_slot', NULL, NULL, 'inc INSERT INTO origin_tbl(data) VALUES ('will be replicated, but not decoded= again'); = -- mark session as replaying -SELECT pg_replication_origin_session_setup('test_decoding: regression_slo= t'); +SELECT pg_replication_origin_session_setup('regress_test_decoding: regres= sion_slot'); = -- ensure we prevent duplicate setup -SELECT pg_replication_origin_session_setup('test_decoding: regression_slo= t'); +SELECT pg_replication_origin_session_setup('regress_test_decoding: regres= sion_slot'); = SELECT '' FROM pg_logical_emit_message(false, 'test', 'this message will = not be decoded'); = @@ -54,8 +54,8 @@ SELECT pg_replication_origin_session_reset(); SELECT local_id, external_id, remote_lsn, local_lsn <> '0/0' FROM pg_repl= ication_origin_status; = -- check replication progress identified by name is correct -SELECT pg_replication_origin_progress('test_decoding: regression_slot', f= alse); -SELECT pg_replication_origin_progress('test_decoding: regression_slot', t= rue); +SELECT pg_replication_origin_progress('regress_test_decoding: regression_= slot', false); +SELECT pg_replication_origin_progress('regress_test_decoding: regression_= slot', true); = -- ensure reset requires previously setup state SELECT pg_replication_origin_session_reset(); @@ -68,4 +68,4 @@ INSERT INTO origin_tbl(data) VALUES ('will be replicated= '); SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NUL= L, 'include-xids', '0', 'skip-empty-xacts', '1', 'only-local', '1'); = SELECT pg_drop_replication_slot('regression_slot'); -SELECT pg_replication_origin_drop('test_decoding: regression_slot'); +SELECT pg_replication_origin_drop('regress_test_decoding: regression_slot= '); diff --git a/contrib/test_decoding/sql/rewrite.sql b/contrib/test_decoding= /sql/rewrite.sql index c9503a0..62dead3 100644 --- a/contrib/test_decoding/sql/rewrite.sql +++ b/contrib/test_decoding/sql/rewrite.sql @@ -13,7 +13,7 @@ CREATE FUNCTION exec(text) returns void language plpgsql= volatile EXECUTE $1; END; $f$; -CREATE ROLE justforcomments NOLOGIN; +CREATE ROLE regress_justforcomments NOLOGIN; = SELECT exec( format($outer$CREATE FUNCTION iamalongfunction() RETURNS TEXT IMMUTAB= LE LANGUAGE SQL AS $f$SELECT text %L$f$$outer$, @@ -22,7 +22,7 @@ SELECT exec( format($outer$COMMENT ON FUNCTION iamalongfunction() IS %L$outer$, iamalongfunction())); SELECT exec( - format($outer$COMMENT ON ROLE JUSTFORCOMMENTS IS %L$outer$, + format($outer$COMMENT ON ROLE REGRESS_JUSTFORCOMMENTS IS %L$outer$, iamalongfunction())); CREATE TABLE iamalargetable AS SELECT iamalongfunction() longfunctionoutp= ut; = @@ -104,4 +104,4 @@ SELECT pg_drop_replication_slot('regression_slot'); DROP TABLE IF EXISTS replication_example; DROP FUNCTION iamalongfunction(); DROP FUNCTION exec(text); -DROP ROLE justforcomments; +DROP ROLE regress_justforcomments; diff --git a/src/bin/pg_dump/t/010_dump_connstr.pl b/src/bin/pg_dump/t/010= _dump_connstr.pl index 28a9eb7..d221682 100644 --- a/src/bin/pg_dump/t/010_dump_connstr.pl +++ b/src/bin/pg_dump/t/010_dump_connstr.pl @@ -22,29 +22,42 @@ $ENV{PGCLIENTENCODING} =3D 'LATIN1'; # Create database and user names covering the range of LATIN1 # characters, for use in a connection string by pg_dumpall. Skip ',' # because of pg_regress --create-role, skip [\n\r] because pg_dumpall -# does not allow them. +# does not allow them. We also skip many ASCII letters, to keep the +# total number of tested characters to what will fit in four names. +# The odds of finding something interesting by testing all ASCII letters +# seem too small to justify the cycles of testing a fifth name. my $dbname1 =3D - generate_ascii_string(1, 9) + 'regression' + . generate_ascii_string(1, 9) . generate_ascii_string(11, 12) . generate_ascii_string(14, 33) - . ($TestLib::windows_os ? '' : '"x"') - . # IPC::Run mishandles '"' on Windows - generate_ascii_string(35, 43) - . generate_ascii_string(45, 63); # contains '=3D' -my $dbname2 =3D - generate_ascii_string(67, 129); # skip 64-66 to keep length to 62 -my $dbname3 =3D generate_ascii_string(130, 192); -my $dbname4 =3D generate_ascii_string(193, 255); + . ($TestLib::windows_os ? '' : '"x"') # IPC::Run mishandles '"' on Wi= ndows + . generate_ascii_string(35, 43) # skip ',' + . generate_ascii_string(45, 54); +my $dbname2 =3D 'regression' . generate_ascii_string(55, 65) # skip 'B= '-'W' + . generate_ascii_string(88, 99) # skip 'd'-= 'w' + . generate_ascii_string(120, 149); +my $dbname3 =3D 'regression' . generate_ascii_string(150, 202); +my $dbname4 =3D 'regression' . generate_ascii_string(203, 255); + +(my $username1 =3D $dbname1) =3D~ s/^regression/regress_/; +(my $username2 =3D $dbname2) =3D~ s/^regression/regress_/; +(my $username3 =3D $dbname3) =3D~ s/^regression/regress_/; +(my $username4 =3D $dbname4) =3D~ s/^regression/regress_/; + +my $src_bootstrap_super =3D 'regress_postgres'; +my $dst_bootstrap_super =3D 'boot'; = my $node =3D get_new_node('main'); -$node->init(extra =3D> [ '--locale=3DC', '--encoding=3DLATIN1' ]); +$node->init(extra =3D> + [ '-U', $src_bootstrap_super, '--locale=3DC', '--encoding=3DLATIN1' ])= ; = # prep pg_hba.conf and pg_ident.conf $node->run_log( [ $ENV{PG_REGRESS}, '--config-auth', $node->data_dir, '--create-role', - "$dbname1,$dbname2,$dbname3,$dbname4" + "$username1,$username2,$username3,$username4" ]); $node->start; = @@ -53,11 +66,18 @@ my $discard =3D "$backupdir/discard.sql"; my $plain =3D "$backupdir/plain.sql"; my $dirfmt =3D "$backupdir/dirfmt"; = -foreach my $dbname ($dbname1, $dbname2, $dbname3, $dbname4, 'CamelCase') -{ - $node->run_log([ 'createdb', $dbname ]); - $node->run_log([ 'createuser', '-s', $dbname ]); -} +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname1 ]); +$node->run_log( + [ 'createuser', '-U', $src_bootstrap_super, '-s', $username1 ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname2 ]); +$node->run_log( + [ 'createuser', '-U', $src_bootstrap_super, '-s', $username2 ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname3 ]); +$node->run_log( + [ 'createuser', '-U', $src_bootstrap_super, '-s', $username3 ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname4 ]); +$node->run_log( + [ 'createuser', '-U', $src_bootstrap_super, '-s', $username4 ]); = = # For these tests, pg_dumpall -r is used because it produces a short @@ -66,98 +86,109 @@ $node->command_ok( [ 'pg_dumpall', '-r', '-f', $discard, '--dbname', $node->connstr($dbname1), - '-U', $dbname4 + '-U', $username4 ], 'pg_dumpall with long ASCII name 1'); $node->command_ok( [ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname', $node->connstr($dbname2), - '-U', $dbname3 + '-U', $username3 ], 'pg_dumpall with long ASCII name 2'); $node->command_ok( [ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname', $node->connstr($dbname3), - '-U', $dbname2 + '-U', $username2 ], 'pg_dumpall with long ASCII name 3'); $node->command_ok( [ 'pg_dumpall', '--no-sync', '-r', '-f', $discard, '--dbname', $node->connstr($dbname4), - '-U', $dbname1 + '-U', $username1 ], 'pg_dumpall with long ASCII name 4'); $node->command_ok( - [ 'pg_dumpall', '--no-sync', '-r', '-l', 'dbname=3Dtemplate1' ], + [ + 'pg_dumpall', '-U', + $src_bootstrap_super, '--no-sync', + '-r', '-l', + 'dbname=3Dtemplate1' + ], 'pg_dumpall -l accepts connection string'); = -$node->run_log([ 'createdb', "foo\n\rbar" ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, "foo\n\rbar" ]); = # not sufficient to use -r here $node->command_fails( - [ 'pg_dumpall', '--no-sync', '-f', $discard ], + [ 'pg_dumpall', '-U', $src_bootstrap_super, '--no-sync', '-f', $discard = ], 'pg_dumpall with \n\r in database name'); -$node->run_log([ 'dropdb', "foo\n\rbar" ]); +$node->run_log([ 'dropdb', '-U', $src_bootstrap_super, "foo\n\rbar" ]); = = # make a table, so the parallel worker has something to dump -$node->safe_psql($dbname1, 'CREATE TABLE t0()'); +$node->safe_psql( + $dbname1, + 'CREATE TABLE t0()', + extra_params =3D> [ '-U', $src_bootstrap_super ]); = # XXX no printed message when this fails, just SIGPIPE termination $node->command_ok( [ - 'pg_dump', '-Fd', '--no-sync', '-j2', '-f', $dirfmt, '-U', $dbname1, + 'pg_dump', '-Fd', '--no-sync', '-j2', '-f', $dirfmt, '-U', $username1, $node->connstr($dbname1) ], 'parallel dump'); = # recreate $dbname1 for restore test -$node->run_log([ 'dropdb', $dbname1 ]); -$node->run_log([ 'createdb', $dbname1 ]); +$node->run_log([ 'dropdb', '-U', $src_bootstrap_super, $dbname1 ]); +$node->run_log([ 'createdb', '-U', $src_bootstrap_super, $dbname1 ]); = $node->command_ok( - [ 'pg_restore', '-v', '-d', 'template1', '-j2', '-U', $dbname1, $dirfmt = ], + [ + 'pg_restore', '-v', '-d', 'template1', + '-j2', '-U', $username1, $dirfmt + ], 'parallel restore'); = -$node->run_log([ 'dropdb', $dbname1 ]); +$node->run_log([ 'dropdb', '-U', $src_bootstrap_super, $dbname1 ]); = $node->command_ok( [ 'pg_restore', '-C', '-v', '-d', - 'template1', '-j2', '-U', $dbname1, + 'template1', '-j2', '-U', $username1, $dirfmt ], 'parallel restore with create'); = = -$node->command_ok([ 'pg_dumpall', '--no-sync', '-f', $plain, '-U', $dbnam= e1 ], +$node->command_ok( + [ 'pg_dumpall', '--no-sync', '-f', $plain, '-U', $username1 ], 'take full dump'); system_log('cat', $plain); my ($stderr, $result); -my $bootstrap_super =3D 'boot'; -my $restore_super =3D qq{a'b\\c=3Dd\\ne"f}; +my $restore_super =3D qq{regress_a'b\\c=3Dd\\ne"f}; = = # Restore full dump through psql using environment variables for # dbname/user connection parameters = my $envar_node =3D get_new_node('destination_envar'); -$envar_node->init( - extra =3D> [ '-U', $bootstrap_super, '--locale=3DC', '--encoding=3DLATIN= 1' ]); +$envar_node->init(extra =3D> + [ '-U', $dst_bootstrap_super, '--locale=3DC', '--encoding=3DLATIN1' ])= ; $envar_node->run_log( [ $ENV{PG_REGRESS}, '--config-auth', $envar_node->data_dir, '--create-role', - "$bootstrap_super,$restore_super" + "$dst_bootstrap_super,$restore_super" ]); $envar_node->start; = # make superuser for restore $envar_node->run_log( - [ 'createuser', '-U', $bootstrap_super, '-s', $restore_super ]); + [ 'createuser', '-U', $dst_bootstrap_super, '-s', $restore_super ]); = { local $ENV{PGPORT} =3D $envar_node->port; @@ -177,17 +208,17 @@ is($stderr, '', 'no dump errors'); $restore_super =3D~ s/"//g if $TestLib::windows_os; # IPC::Run mishandles '"' on Windows my $cmdline_node =3D get_new_node('destination_cmdline'); -$cmdline_node->init( - extra =3D> [ '-U', $bootstrap_super, '--locale=3DC', '--encoding=3DLATIN= 1' ]); +$cmdline_node->init(extra =3D> + [ '-U', $dst_bootstrap_super, '--locale=3DC', '--encoding=3DLATIN1' ])= ; $cmdline_node->run_log( [ $ENV{PG_REGRESS}, '--config-auth', $cmdline_node->data_dir, '--create-role', - "$bootstrap_super,$restore_super" + "$dst_bootstrap_super,$restore_super" ]); $cmdline_node->start; $cmdline_node->run_log( - [ 'createuser', '-U', $bootstrap_super, '-s', $restore_super ]); + [ 'createuser', '-U', $dst_bootstrap_super, '-s', $restore_super ]); { $result =3D run_log( [ diff --git a/src/bin/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh index d6d196a..7882024 100644 --- a/src/bin/pg_upgrade/test.sh +++ b/src/bin/pg_upgrade/test.sh @@ -159,9 +159,9 @@ dbname1=3D`awk 'BEGIN { for (i=3D 1; i < 46; i++) dbname1=3D'\"\'$dbname1'\\"\\\' dbname2=3D`awk 'BEGIN { for (i =3D 46; i < 91; i++) printf "%c", i }'