mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Avoid using unsafe search_path settings during dump and restore.
Historically, pg_dump has "set search_path = foo, pg_catalog" when dumping an object in schema "foo", and has also caused that setting to be used while restoring the object. This is problematic because functions and operators in schema "foo" could capture references meant to refer to pg_catalog entries, both in the queries issued by pg_dump and those issued during the subsequent restore run. That could result in dump/restore misbehavior, or in privilege escalation if a nefarious user installs trojan-horse functions or operators. This patch changes pg_dump so that it does not change the search_path dynamically. The emitted restore script sets the search_path to what was used at dump time, and then leaves it alone thereafter. Created objects are placed in the correct schema, regardless of the active search_path, by dint of schema-qualifying their names in the CREATE commands, as well as in subsequent ALTER and ALTER-like commands. Since this change requires a change in the behavior of pg_restore when processing an archive file made according to this new convention, bump the archive file version number; old versions of pg_restore will therefore refuse to process files made with new versions of pg_dump. Security: CVE-2018-1058
This commit is contained in:
parent
bcce4c3bc7
commit
815172ba80
@ -82,15 +82,17 @@
|
||||
#define PRETTYINDENT_LIMIT 40 /* wrap limit */
|
||||
|
||||
/* Pretty flags */
|
||||
#define PRETTYFLAG_PAREN 1
|
||||
#define PRETTYFLAG_INDENT 2
|
||||
#define PRETTYFLAG_PAREN 0x0001
|
||||
#define PRETTYFLAG_INDENT 0x0002
|
||||
#define PRETTYFLAG_SCHEMA 0x0004
|
||||
|
||||
/* Default line length for pretty-print wrapping: 0 means wrap always */
|
||||
#define WRAP_COLUMN_DEFAULT 0
|
||||
|
||||
/* macro to test if pretty action needed */
|
||||
/* macros to test if pretty action needed */
|
||||
#define PRETTY_PAREN(context) ((context)->prettyFlags & PRETTYFLAG_PAREN)
|
||||
#define PRETTY_INDENT(context) ((context)->prettyFlags & PRETTYFLAG_INDENT)
|
||||
#define PRETTY_SCHEMA(context) ((context)->prettyFlags & PRETTYFLAG_SCHEMA)
|
||||
|
||||
|
||||
/* ----------
|
||||
@ -489,7 +491,7 @@ pg_get_ruledef_ext(PG_FUNCTION_ARGS)
|
||||
int prettyFlags;
|
||||
char *res;
|
||||
|
||||
prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : PRETTYFLAG_INDENT;
|
||||
prettyFlags = pretty ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) : PRETTYFLAG_INDENT;
|
||||
|
||||
res = pg_get_ruledef_worker(ruleoid, prettyFlags);
|
||||
|
||||
@ -610,7 +612,7 @@ pg_get_viewdef_ext(PG_FUNCTION_ARGS)
|
||||
int prettyFlags;
|
||||
char *res;
|
||||
|
||||
prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : PRETTYFLAG_INDENT;
|
||||
prettyFlags = pretty ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) : PRETTYFLAG_INDENT;
|
||||
|
||||
res = pg_get_viewdef_worker(viewoid, prettyFlags, WRAP_COLUMN_DEFAULT);
|
||||
|
||||
@ -630,7 +632,7 @@ pg_get_viewdef_wrap(PG_FUNCTION_ARGS)
|
||||
char *res;
|
||||
|
||||
/* calling this implies we want pretty printing */
|
||||
prettyFlags = PRETTYFLAG_PAREN | PRETTYFLAG_INDENT;
|
||||
prettyFlags = PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA;
|
||||
|
||||
res = pg_get_viewdef_worker(viewoid, prettyFlags, wrap);
|
||||
|
||||
@ -676,7 +678,7 @@ pg_get_viewdef_name_ext(PG_FUNCTION_ARGS)
|
||||
Oid viewoid;
|
||||
char *res;
|
||||
|
||||
prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : PRETTYFLAG_INDENT;
|
||||
prettyFlags = pretty ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) : PRETTYFLAG_INDENT;
|
||||
|
||||
/* Look up view name. Can't lock it - we might not have privileges. */
|
||||
viewrel = makeRangeVarFromNameList(textToQualifiedNameList(viewname));
|
||||
@ -910,8 +912,15 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
|
||||
appendStringInfoString(&buf, " TRUNCATE");
|
||||
findx++;
|
||||
}
|
||||
|
||||
/*
|
||||
* In non-pretty mode, always schema-qualify the target table name for
|
||||
* safety. In pretty mode, schema-qualify only if not visible.
|
||||
*/
|
||||
appendStringInfo(&buf, " ON %s ",
|
||||
generate_relation_name(trigrec->tgrelid, NIL));
|
||||
pretty ?
|
||||
generate_relation_name(trigrec->tgrelid, NIL) :
|
||||
generate_qualified_relation_name(trigrec->tgrelid));
|
||||
|
||||
if (OidIsValid(trigrec->tgconstraint))
|
||||
{
|
||||
@ -984,7 +993,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
|
||||
context.windowClause = NIL;
|
||||
context.windowTList = NIL;
|
||||
context.varprefix = true;
|
||||
context.prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : PRETTYFLAG_INDENT;
|
||||
context.prettyFlags = pretty ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) : PRETTYFLAG_INDENT;
|
||||
context.wrapColumn = WRAP_COLUMN_DEFAULT;
|
||||
context.indentLevel = PRETTYINDENT_STD;
|
||||
context.special_exprkind = EXPR_KIND_NONE;
|
||||
@ -1071,7 +1080,7 @@ pg_get_indexdef_ext(PG_FUNCTION_ARGS)
|
||||
int prettyFlags;
|
||||
char *res;
|
||||
|
||||
prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : PRETTYFLAG_INDENT;
|
||||
prettyFlags = pretty ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) : PRETTYFLAG_INDENT;
|
||||
|
||||
res = pg_get_indexdef_worker(indexrelid, colno, NULL, colno != 0, false,
|
||||
prettyFlags, true);
|
||||
@ -1099,7 +1108,8 @@ pg_get_indexdef_columns(Oid indexrelid, bool pretty)
|
||||
{
|
||||
int prettyFlags;
|
||||
|
||||
prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : PRETTYFLAG_INDENT;
|
||||
prettyFlags = pretty ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) : PRETTYFLAG_INDENT;
|
||||
|
||||
return pg_get_indexdef_worker(indexrelid, 0, NULL, true, false,
|
||||
prettyFlags, false);
|
||||
}
|
||||
@ -1229,7 +1239,9 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
|
||||
appendStringInfo(&buf, "CREATE %sINDEX %s ON %s USING %s (",
|
||||
idxrec->indisunique ? "UNIQUE " : "",
|
||||
quote_identifier(NameStr(idxrelrec->relname)),
|
||||
generate_relation_name(indrelid, NIL),
|
||||
(prettyFlags & PRETTYFLAG_SCHEMA) ?
|
||||
generate_relation_name(indrelid, NIL) :
|
||||
generate_qualified_relation_name(indrelid),
|
||||
quote_identifier(NameStr(amrec->amname)));
|
||||
else /* currently, must be EXCLUDE constraint */
|
||||
appendStringInfo(&buf, "EXCLUDE USING %s (",
|
||||
@ -1427,7 +1439,7 @@ pg_get_constraintdef_ext(PG_FUNCTION_ARGS)
|
||||
int prettyFlags;
|
||||
char *res;
|
||||
|
||||
prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : PRETTYFLAG_INDENT;
|
||||
prettyFlags = pretty ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) : PRETTYFLAG_INDENT;
|
||||
|
||||
res = pg_get_constraintdef_worker(constraintId, false, prettyFlags, true);
|
||||
|
||||
@ -1869,7 +1881,7 @@ pg_get_expr_ext(PG_FUNCTION_ARGS)
|
||||
int prettyFlags;
|
||||
char *relname;
|
||||
|
||||
prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : PRETTYFLAG_INDENT;
|
||||
prettyFlags = pretty ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) : PRETTYFLAG_INDENT;
|
||||
|
||||
if (OidIsValid(relid))
|
||||
{
|
||||
@ -4300,7 +4312,10 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc,
|
||||
}
|
||||
|
||||
/* The relation the rule is fired on */
|
||||
appendStringInfo(buf, " TO %s", generate_relation_name(ev_class, NIL));
|
||||
appendStringInfo(buf, " TO %s",
|
||||
(prettyFlags & PRETTYFLAG_SCHEMA) ?
|
||||
generate_relation_name(ev_class, NIL) :
|
||||
generate_qualified_relation_name(ev_class));
|
||||
|
||||
/* If the rule has an event qualification, add it */
|
||||
if (ev_qual == NULL)
|
||||
|
@ -34,6 +34,7 @@ static void AddAcl(PQExpBuffer aclbuf, const char *keyword,
|
||||
*
|
||||
* name: the object name, in the form to use in the commands (already quoted)
|
||||
* subname: the sub-object name, if any (already quoted); NULL if none
|
||||
* nspname: the namespace the object is in (NULL if none); not pre-quoted
|
||||
* type: the object type (as seen in GRANT command: must be one of
|
||||
* TABLE, SEQUENCE, FUNCTION, LANGUAGE, SCHEMA, DATABASE, TABLESPACE,
|
||||
* FOREIGN DATA WRAPPER, SERVER, or LARGE OBJECT)
|
||||
@ -54,7 +55,7 @@ static void AddAcl(PQExpBuffer aclbuf, const char *keyword,
|
||||
* since this routine uses fmtId() internally.
|
||||
*/
|
||||
bool
|
||||
buildACLCommands(const char *name, const char *subname,
|
||||
buildACLCommands(const char *name, const char *subname, const char *nspname,
|
||||
const char *type, const char *acls, const char *racls,
|
||||
const char *owner, const char *prefix, int remoteVersion,
|
||||
PQExpBuffer sql)
|
||||
@ -154,7 +155,10 @@ buildACLCommands(const char *name, const char *subname,
|
||||
appendPQExpBuffer(firstsql, "%sREVOKE ALL", prefix);
|
||||
if (subname)
|
||||
appendPQExpBuffer(firstsql, "(%s)", subname);
|
||||
appendPQExpBuffer(firstsql, " ON %s %s FROM PUBLIC;\n", type, name);
|
||||
appendPQExpBuffer(firstsql, " ON %s ", type);
|
||||
if (nspname && *nspname)
|
||||
appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
|
||||
appendPQExpBuffer(firstsql, "%s FROM PUBLIC;\n", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -172,8 +176,11 @@ buildACLCommands(const char *name, const char *subname,
|
||||
{
|
||||
if (privs->len > 0)
|
||||
{
|
||||
appendPQExpBuffer(firstsql, "%sREVOKE %s ON %s %s FROM ",
|
||||
prefix, privs->data, type, name);
|
||||
appendPQExpBuffer(firstsql, "%sREVOKE %s ON %s ",
|
||||
prefix, privs->data, type);
|
||||
if (nspname && *nspname)
|
||||
appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
|
||||
appendPQExpBuffer(firstsql, "%s FROM ", name);
|
||||
if (grantee->len == 0)
|
||||
appendPQExpBufferStr(firstsql, "PUBLIC;\n");
|
||||
else if (strncmp(grantee->data, "group ",
|
||||
@ -187,8 +194,11 @@ buildACLCommands(const char *name, const char *subname,
|
||||
if (privswgo->len > 0)
|
||||
{
|
||||
appendPQExpBuffer(firstsql,
|
||||
"%sREVOKE GRANT OPTION FOR %s ON %s %s FROM ",
|
||||
prefix, privswgo->data, type, name);
|
||||
"%sREVOKE GRANT OPTION FOR %s ON %s ",
|
||||
prefix, privswgo->data, type);
|
||||
if (nspname && *nspname)
|
||||
appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
|
||||
appendPQExpBuffer(firstsql, "%s FROM ", name);
|
||||
if (grantee->len == 0)
|
||||
appendPQExpBufferStr(firstsql, "PUBLIC");
|
||||
else if (strncmp(grantee->data, "group ",
|
||||
@ -255,18 +265,33 @@ buildACLCommands(const char *name, const char *subname,
|
||||
appendPQExpBuffer(firstsql, "%sREVOKE ALL", prefix);
|
||||
if (subname)
|
||||
appendPQExpBuffer(firstsql, "(%s)", subname);
|
||||
appendPQExpBuffer(firstsql, " ON %s %s FROM %s;\n",
|
||||
type, name, fmtId(grantee->data));
|
||||
appendPQExpBuffer(firstsql, " ON %s ", type);
|
||||
if (nspname && *nspname)
|
||||
appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
|
||||
appendPQExpBuffer(firstsql, "%s FROM %s;\n",
|
||||
name, fmtId(grantee->data));
|
||||
if (privs->len > 0)
|
||||
{
|
||||
appendPQExpBuffer(firstsql,
|
||||
"%sGRANT %s ON %s %s TO %s;\n",
|
||||
prefix, privs->data, type, name,
|
||||
fmtId(grantee->data));
|
||||
"%sGRANT %s ON %s ",
|
||||
prefix, privs->data, type);
|
||||
if (nspname && *nspname)
|
||||
appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
|
||||
appendPQExpBuffer(firstsql,
|
||||
"%s TO %s;\n",
|
||||
name, fmtId(grantee->data));
|
||||
}
|
||||
if (privswgo->len > 0)
|
||||
{
|
||||
appendPQExpBuffer(firstsql,
|
||||
"%sGRANT %s ON %s %s TO %s WITH GRANT OPTION;\n",
|
||||
prefix, privswgo->data, type, name,
|
||||
fmtId(grantee->data));
|
||||
"%sGRANT %s ON %s ",
|
||||
prefix, privswgo->data, type);
|
||||
if (nspname && *nspname)
|
||||
appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
|
||||
appendPQExpBuffer(firstsql,
|
||||
"%s TO %s WITH GRANT OPTION;\n",
|
||||
name, fmtId(grantee->data));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -288,8 +313,11 @@ buildACLCommands(const char *name, const char *subname,
|
||||
|
||||
if (privs->len > 0)
|
||||
{
|
||||
appendPQExpBuffer(secondsql, "%sGRANT %s ON %s %s TO ",
|
||||
prefix, privs->data, type, name);
|
||||
appendPQExpBuffer(secondsql, "%sGRANT %s ON %s ",
|
||||
prefix, privs->data, type);
|
||||
if (nspname && *nspname)
|
||||
appendPQExpBuffer(secondsql, "%s.", fmtId(nspname));
|
||||
appendPQExpBuffer(secondsql, "%s TO ", name);
|
||||
if (grantee->len == 0)
|
||||
appendPQExpBufferStr(secondsql, "PUBLIC;\n");
|
||||
else if (strncmp(grantee->data, "group ",
|
||||
@ -301,8 +329,11 @@ buildACLCommands(const char *name, const char *subname,
|
||||
}
|
||||
if (privswgo->len > 0)
|
||||
{
|
||||
appendPQExpBuffer(secondsql, "%sGRANT %s ON %s %s TO ",
|
||||
prefix, privswgo->data, type, name);
|
||||
appendPQExpBuffer(secondsql, "%sGRANT %s ON %s ",
|
||||
prefix, privswgo->data, type);
|
||||
if (nspname && *nspname)
|
||||
appendPQExpBuffer(secondsql, "%s.", fmtId(nspname));
|
||||
appendPQExpBuffer(secondsql, "%s TO ", name);
|
||||
if (grantee->len == 0)
|
||||
appendPQExpBufferStr(secondsql, "PUBLIC");
|
||||
else if (strncmp(grantee->data, "group ",
|
||||
@ -332,8 +363,11 @@ buildACLCommands(const char *name, const char *subname,
|
||||
appendPQExpBuffer(firstsql, "%sREVOKE ALL", prefix);
|
||||
if (subname)
|
||||
appendPQExpBuffer(firstsql, "(%s)", subname);
|
||||
appendPQExpBuffer(firstsql, " ON %s %s FROM %s;\n",
|
||||
type, name, fmtId(owner));
|
||||
appendPQExpBuffer(firstsql, " ON %s ", type);
|
||||
if (nspname && *nspname)
|
||||
appendPQExpBuffer(firstsql, "%s.", fmtId(nspname));
|
||||
appendPQExpBuffer(firstsql, "%s FROM %s;\n",
|
||||
name, fmtId(owner));
|
||||
}
|
||||
|
||||
destroyPQExpBuffer(grantee);
|
||||
@ -392,7 +426,8 @@ buildDefaultACLCommands(const char *type, const char *nspname,
|
||||
if (strlen(initacls) != 0 || strlen(initracls) != 0)
|
||||
{
|
||||
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\n");
|
||||
if (!buildACLCommands("", NULL, type, initacls, initracls, owner,
|
||||
if (!buildACLCommands("", NULL, NULL, type,
|
||||
initacls, initracls, owner,
|
||||
prefix->data, remoteVersion, sql))
|
||||
{
|
||||
destroyPQExpBuffer(prefix);
|
||||
@ -401,7 +436,8 @@ buildDefaultACLCommands(const char *type, const char *nspname,
|
||||
appendPQExpBuffer(sql, "SELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\n");
|
||||
}
|
||||
|
||||
if (!buildACLCommands("", NULL, type, acls, racls, owner,
|
||||
if (!buildACLCommands("", NULL, NULL, type,
|
||||
acls, racls, owner,
|
||||
prefix->data, remoteVersion, sql))
|
||||
{
|
||||
destroyPQExpBuffer(prefix);
|
||||
@ -645,26 +681,32 @@ AddAcl(PQExpBuffer aclbuf, const char *keyword, const char *subname)
|
||||
* buildShSecLabelQuery
|
||||
*
|
||||
* Build a query to retrieve security labels for a shared object.
|
||||
* The object is identified by its OID plus the name of the catalog
|
||||
* it can be found in (e.g., "pg_database" for database names).
|
||||
* The query is appended to "sql". (We don't execute it here so as to
|
||||
* keep this file free of assumptions about how to deal with SQL errors.)
|
||||
*/
|
||||
void
|
||||
buildShSecLabelQuery(PGconn *conn, const char *catalog_name, uint32 objectId,
|
||||
buildShSecLabelQuery(PGconn *conn, const char *catalog_name, Oid objectId,
|
||||
PQExpBuffer sql)
|
||||
{
|
||||
appendPQExpBuffer(sql,
|
||||
"SELECT provider, label FROM pg_catalog.pg_shseclabel "
|
||||
"WHERE classoid = '%s'::pg_catalog.regclass AND "
|
||||
"objoid = %u", catalog_name, objectId);
|
||||
"WHERE classoid = 'pg_catalog.%s'::pg_catalog.regclass "
|
||||
"AND objoid = '%u'", catalog_name, objectId);
|
||||
}
|
||||
|
||||
/*
|
||||
* emitShSecLabels
|
||||
*
|
||||
* Format security label data retrieved by the query generated in
|
||||
* buildShSecLabelQuery.
|
||||
* Construct SECURITY LABEL commands using the data retrieved by the query
|
||||
* generated by buildShSecLabelQuery, and append them to "buffer".
|
||||
* Here, the target object is identified by its type name (e.g. "DATABASE")
|
||||
* and its name (not pre-quoted).
|
||||
*/
|
||||
void
|
||||
emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer,
|
||||
const char *target, const char *objname)
|
||||
const char *objtype, const char *objname)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -676,7 +718,7 @@ emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer,
|
||||
/* must use fmtId result before calling it again */
|
||||
appendPQExpBuffer(buffer,
|
||||
"SECURITY LABEL FOR %s ON %s",
|
||||
fmtId(provider), target);
|
||||
fmtId(provider), objtype);
|
||||
appendPQExpBuffer(buffer,
|
||||
" %s IS ",
|
||||
fmtId(objname));
|
||||
|
@ -36,7 +36,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
extern bool buildACLCommands(const char *name, const char *subname,
|
||||
extern bool buildACLCommands(const char *name, const char *subname, const char *nspname,
|
||||
const char *type, const char *acls, const char *racls,
|
||||
const char *owner, const char *prefix, int remoteVersion,
|
||||
PQExpBuffer sql);
|
||||
@ -47,9 +47,9 @@ extern bool buildDefaultACLCommands(const char *type, const char *nspname,
|
||||
int remoteVersion,
|
||||
PQExpBuffer sql);
|
||||
extern void buildShSecLabelQuery(PGconn *conn, const char *catalog_name,
|
||||
uint32 objectId, PQExpBuffer sql);
|
||||
Oid objectId, PQExpBuffer sql);
|
||||
extern void emitShSecLabels(PGconn *conn, PGresult *res,
|
||||
PQExpBuffer buffer, const char *target, const char *objname);
|
||||
PQExpBuffer buffer, const char *objtype, const char *objname);
|
||||
|
||||
extern void buildACLQueries(PQExpBuffer acl_subquery, PQExpBuffer racl_subquery,
|
||||
PQExpBuffer init_acl_subquery, PQExpBuffer init_racl_subquery,
|
||||
|
@ -186,6 +186,9 @@ typedef struct Archive
|
||||
/* info needed for string escaping */
|
||||
int encoding; /* libpq code for client_encoding */
|
||||
bool std_strings; /* standard_conforming_strings */
|
||||
|
||||
/* other important stuff */
|
||||
char *searchpath; /* search_path to set during restore */
|
||||
char *use_role; /* Issue SET ROLE to this */
|
||||
|
||||
/* error handling */
|
||||
|
@ -71,6 +71,7 @@ static void _selectOutputSchema(ArchiveHandle *AH, const char *schemaName);
|
||||
static void _selectTablespace(ArchiveHandle *AH, const char *tablespace);
|
||||
static void processEncodingEntry(ArchiveHandle *AH, TocEntry *te);
|
||||
static void processStdStringsEntry(ArchiveHandle *AH, TocEntry *te);
|
||||
static void processSearchPathEntry(ArchiveHandle *AH, TocEntry *te);
|
||||
static teReqs _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt);
|
||||
static RestorePass _tocEntryRestorePass(TocEntry *te);
|
||||
static bool _tocEntryIsACL(TocEntry *te);
|
||||
@ -895,7 +896,9 @@ restore_toc_entry(ArchiveHandle *AH, TocEntry *te, bool is_parallel)
|
||||
ahprintf(AH, "TRUNCATE TABLE %s%s;\n\n",
|
||||
(PQserverVersion(AH->connection) >= 80400 ?
|
||||
"ONLY " : ""),
|
||||
fmtId(te->tag));
|
||||
fmtQualifiedId(PQserverVersion(AH->connection),
|
||||
te->namespace,
|
||||
te->tag));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -982,10 +985,10 @@ _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te)
|
||||
/*
|
||||
* Disable them.
|
||||
*/
|
||||
_selectOutputSchema(AH, te->namespace);
|
||||
|
||||
ahprintf(AH, "ALTER TABLE %s DISABLE TRIGGER ALL;\n\n",
|
||||
fmtId(te->tag));
|
||||
fmtQualifiedId(PQserverVersion(AH->connection),
|
||||
te->namespace,
|
||||
te->tag));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1010,10 +1013,10 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te)
|
||||
/*
|
||||
* Enable them.
|
||||
*/
|
||||
_selectOutputSchema(AH, te->namespace);
|
||||
|
||||
ahprintf(AH, "ALTER TABLE %s ENABLE TRIGGER ALL;\n\n",
|
||||
fmtId(te->tag));
|
||||
fmtQualifiedId(PQserverVersion(AH->connection),
|
||||
te->namespace,
|
||||
te->tag));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2683,6 +2686,8 @@ ReadToc(ArchiveHandle *AH)
|
||||
processEncodingEntry(AH, te);
|
||||
else if (strcmp(te->desc, "STDSTRINGS") == 0)
|
||||
processStdStringsEntry(AH, te);
|
||||
else if (strcmp(te->desc, "SEARCHPATH") == 0)
|
||||
processSearchPathEntry(AH, te);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2730,6 +2735,16 @@ processStdStringsEntry(ArchiveHandle *AH, TocEntry *te)
|
||||
te->defn);
|
||||
}
|
||||
|
||||
static void
|
||||
processSearchPathEntry(ArchiveHandle *AH, TocEntry *te)
|
||||
{
|
||||
/*
|
||||
* te->defn should contain a command to set search_path. We just copy it
|
||||
* verbatim for use later.
|
||||
*/
|
||||
AH->public.searchpath = pg_strdup(te->defn);
|
||||
}
|
||||
|
||||
static void
|
||||
StrictNamesCheck(RestoreOptions *ropt)
|
||||
{
|
||||
@ -2778,9 +2793,10 @@ _tocEntryRequired(TocEntry *te, teSection curSection, RestoreOptions *ropt)
|
||||
{
|
||||
teReqs res = REQ_SCHEMA | REQ_DATA;
|
||||
|
||||
/* ENCODING and STDSTRINGS items are treated specially */
|
||||
/* These items are treated specially */
|
||||
if (strcmp(te->desc, "ENCODING") == 0 ||
|
||||
strcmp(te->desc, "STDSTRINGS") == 0)
|
||||
strcmp(te->desc, "STDSTRINGS") == 0 ||
|
||||
strcmp(te->desc, "SEARCHPATH") == 0)
|
||||
return REQ_SPECIAL;
|
||||
|
||||
/* If it's an ACL, maybe ignore it */
|
||||
@ -2993,6 +3009,10 @@ _doSetFixedOutputState(ArchiveHandle *AH)
|
||||
if (ropt && ropt->use_role)
|
||||
ahprintf(AH, "SET ROLE %s;\n", fmtId(ropt->use_role));
|
||||
|
||||
/* Select the dump-time search_path */
|
||||
if (AH->public.searchpath)
|
||||
ahprintf(AH, "%s", AH->public.searchpath);
|
||||
|
||||
/* Make sure function checking is disabled */
|
||||
ahprintf(AH, "SET check_function_bodies = false;\n");
|
||||
|
||||
@ -3197,6 +3217,15 @@ _selectOutputSchema(ArchiveHandle *AH, const char *schemaName)
|
||||
{
|
||||
PQExpBuffer qry;
|
||||
|
||||
/*
|
||||
* If there was a SEARCHPATH TOC entry, we're supposed to just stay with
|
||||
* that search_path rather than switching to entry-specific paths.
|
||||
* Otherwise, it's an old archive that will not restore correctly unless
|
||||
* we set the search_path as it's expecting.
|
||||
*/
|
||||
if (AH->public.searchpath)
|
||||
return;
|
||||
|
||||
if (!schemaName || *schemaName == '\0' ||
|
||||
(AH->currSchema && strcmp(AH->currSchema, schemaName) == 0))
|
||||
return; /* no need to do anything */
|
||||
@ -3326,8 +3355,10 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
|
||||
strcmp(type, "SERVER") == 0 ||
|
||||
strcmp(type, "USER MAPPING") == 0)
|
||||
{
|
||||
/* We already know that search_path was set properly */
|
||||
appendPQExpBuffer(buf, "%s %s", type, fmtId(te->tag));
|
||||
appendPQExpBuffer(buf, "%s ", type);
|
||||
if (te->namespace && *te->namespace)
|
||||
appendPQExpBuffer(buf, "%s.", fmtId(te->namespace));
|
||||
appendPQExpBufferStr(buf, fmtId(te->tag));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ typedef z_stream *z_streamp;
|
||||
|
||||
/* Current archive version number (the format we can output) */
|
||||
#define K_VERS_MAJOR 1
|
||||
#define K_VERS_MINOR 12
|
||||
#define K_VERS_MINOR 13
|
||||
#define K_VERS_REV 0
|
||||
|
||||
/* Data block types */
|
||||
@ -90,9 +90,11 @@ typedef z_stream *z_streamp;
|
||||
* indicator */
|
||||
#define K_VERS_1_12 (( (1 * 256 + 12) * 256 + 0) * 256 + 0) /* add separate BLOB
|
||||
* entries */
|
||||
#define K_VERS_1_13 (( (1 * 256 + 13) * 256 + 0) * 256 + 0) /* change search_path
|
||||
* behavior */
|
||||
|
||||
/* Newest format we can read */
|
||||
#define K_VERS_MAX (( (1 * 256 + 12) * 256 + 255) * 256 + 0)
|
||||
#define K_VERS_MAX (( (1 * 256 + 13) * 256 + 255) * 256 + 0)
|
||||
|
||||
|
||||
/* Flags to indicate disposition of offsets stored in files */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -52,9 +52,10 @@ static void dumpDatabases(PGconn *conn);
|
||||
static void dumpTimestamp(const char *msg);
|
||||
|
||||
static int runPgDump(const char *dbname);
|
||||
static void buildShSecLabels(PGconn *conn, const char *catalog_name,
|
||||
uint32 objectId, PQExpBuffer buffer,
|
||||
const char *target, const char *objname);
|
||||
static void buildShSecLabels(PGconn *conn,
|
||||
const char *catalog_name, Oid objectId,
|
||||
const char *objtype, const char *objname,
|
||||
PQExpBuffer buffer);
|
||||
static PGconn *connectDatabase(const char *dbname, const char *connstr, const char *pghost, const char *pgport,
|
||||
const char *pguser, trivalue prompt_password, bool fail_on_error);
|
||||
static char *constructConnStr(const char **keywords, const char **values);
|
||||
@ -877,7 +878,8 @@ dumpRoles(PGconn *conn)
|
||||
|
||||
if (!no_security_labels && server_version >= 90200)
|
||||
buildShSecLabels(conn, "pg_authid", auth_oid,
|
||||
buf, "ROLE", rolename);
|
||||
"ROLE", rolename,
|
||||
buf);
|
||||
|
||||
fprintf(OPF, "%s", buf->data);
|
||||
}
|
||||
@ -1138,7 +1140,7 @@ dumpTablespaces(PGconn *conn)
|
||||
for (i = 0; i < PQntuples(res); i++)
|
||||
{
|
||||
PQExpBuffer buf = createPQExpBuffer();
|
||||
uint32 spcoid = atooid(PQgetvalue(res, i, 0));
|
||||
Oid spcoid = atooid(PQgetvalue(res, i, 0));
|
||||
char *spcname = PQgetvalue(res, i, 1);
|
||||
char *spcowner = PQgetvalue(res, i, 2);
|
||||
char *spclocation = PQgetvalue(res, i, 3);
|
||||
@ -1163,11 +1165,12 @@ dumpTablespaces(PGconn *conn)
|
||||
fspcname, spcoptions);
|
||||
|
||||
if (!skip_acls &&
|
||||
!buildACLCommands(fspcname, NULL, "TABLESPACE", spcacl, rspcacl,
|
||||
!buildACLCommands(fspcname, NULL, NULL, "TABLESPACE",
|
||||
spcacl, rspcacl,
|
||||
spcowner, "", server_version, buf))
|
||||
{
|
||||
fprintf(stderr, _("%s: could not parse ACL list (%s) for tablespace \"%s\"\n"),
|
||||
progname, spcacl, fspcname);
|
||||
progname, spcacl, spcname);
|
||||
PQfinish(conn);
|
||||
exit_nicely(1);
|
||||
}
|
||||
@ -1181,7 +1184,8 @@ dumpTablespaces(PGconn *conn)
|
||||
|
||||
if (!no_security_labels && server_version >= 90200)
|
||||
buildShSecLabels(conn, "pg_tablespace", spcoid,
|
||||
buf, "TABLESPACE", fspcname);
|
||||
"TABLESPACE", spcname,
|
||||
buf);
|
||||
|
||||
fprintf(OPF, "%s", buf->data);
|
||||
|
||||
@ -1530,7 +1534,7 @@ dumpCreateDB(PGconn *conn)
|
||||
}
|
||||
|
||||
if (!skip_acls &&
|
||||
!buildACLCommands(fdbname, NULL, "DATABASE",
|
||||
!buildACLCommands(fdbname, NULL, NULL, "DATABASE",
|
||||
dbacl, rdbacl, dbowner,
|
||||
"", server_version, buf))
|
||||
{
|
||||
@ -1848,19 +1852,23 @@ runPgDump(const char *dbname)
|
||||
*
|
||||
* Build SECURITY LABEL command(s) for a shared object
|
||||
*
|
||||
* The caller has to provide object type and identifier to select security
|
||||
* labels from pg_seclabels system view.
|
||||
* The caller has to provide object type and identity in two separate formats:
|
||||
* catalog_name (e.g., "pg_database") and object OID, as well as
|
||||
* type name (e.g., "DATABASE") and object name (not pre-quoted).
|
||||
*
|
||||
* The command(s) are appended to "buffer".
|
||||
*/
|
||||
static void
|
||||
buildShSecLabels(PGconn *conn, const char *catalog_name, uint32 objectId,
|
||||
PQExpBuffer buffer, const char *target, const char *objname)
|
||||
buildShSecLabels(PGconn *conn, const char *catalog_name, Oid objectId,
|
||||
const char *objtype, const char *objname,
|
||||
PQExpBuffer buffer)
|
||||
{
|
||||
PQExpBuffer sql = createPQExpBuffer();
|
||||
PGresult *res;
|
||||
|
||||
buildShSecLabelQuery(conn, catalog_name, objectId, sql);
|
||||
res = executeQuery(conn, sql->data);
|
||||
emitShSecLabels(conn, res, buffer, target, objname);
|
||||
emitShSecLabels(conn, res, buffer, objtype, objname);
|
||||
|
||||
PQclear(res);
|
||||
destroyPQExpBuffer(sql);
|
||||
|
@ -363,7 +363,7 @@ my %tests = (
|
||||
test_schema_plus_blobs => 1, }, },
|
||||
'ALTER SEQUENCE test_table_col1_seq' => {
|
||||
regexp => qr/^
|
||||
\QALTER SEQUENCE test_table_col1_seq OWNED BY test_table.col1;\E
|
||||
\QALTER SEQUENCE dump_test.test_table_col1_seq OWNED BY dump_test.test_table.col1;\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -388,7 +388,7 @@ my %tests = (
|
||||
section_post_data => 1, }, },
|
||||
'ALTER SEQUENCE test_third_table_col1_seq' => {
|
||||
regexp => qr/^
|
||||
\QALTER SEQUENCE test_third_table_col1_seq OWNED BY test_third_table.col1;\E
|
||||
\QALTER SEQUENCE dump_test_second_schema.test_third_table_col1_seq OWNED BY dump_test_second_schema.test_third_table.col1;\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -413,7 +413,7 @@ my %tests = (
|
||||
test_schema_plus_blobs => 1, }, },
|
||||
'ALTER TABLE ONLY test_table ADD CONSTRAINT ... PRIMARY KEY' => {
|
||||
regexp => qr/^
|
||||
\QALTER TABLE ONLY test_table\E \n^\s+
|
||||
\QALTER TABLE ONLY dump_test.test_table\E \n^\s+
|
||||
\QADD CONSTRAINT test_table_pkey PRIMARY KEY (col1);\E
|
||||
/xm,
|
||||
like => {
|
||||
@ -436,7 +436,7 @@ my %tests = (
|
||||
section_pre_data => 1,
|
||||
section_data => 1, }, },
|
||||
'ALTER TABLE test_table OWNER TO' => {
|
||||
regexp => qr/^ALTER TABLE test_table OWNER TO .*;/m,
|
||||
regexp => qr/^ALTER TABLE dump_test.test_table OWNER TO .*;/m,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
clean => 1,
|
||||
@ -458,7 +458,7 @@ my %tests = (
|
||||
create_order => 23,
|
||||
create_sql => 'ALTER TABLE dump_test.test_table
|
||||
ENABLE ROW LEVEL SECURITY;',
|
||||
regexp => qr/^ALTER TABLE test_table ENABLE ROW LEVEL SECURITY;/m,
|
||||
regexp => qr/^ALTER TABLE dump_test.test_table ENABLE ROW LEVEL SECURITY;/m,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
clean => 1,
|
||||
@ -478,7 +478,7 @@ my %tests = (
|
||||
exclude_dump_test_schema => 1,
|
||||
exclude_test_table => 1, }, },
|
||||
'ALTER TABLE test_second_table OWNER TO' => {
|
||||
regexp => qr/^ALTER TABLE test_second_table OWNER TO .*;/m,
|
||||
regexp => qr/^ALTER TABLE dump_test.test_second_table OWNER TO .*;/m,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
clean => 1,
|
||||
@ -497,7 +497,7 @@ my %tests = (
|
||||
exclude_dump_test_schema => 1,
|
||||
only_dump_test_table => 1, }, },
|
||||
'ALTER TABLE test_third_table OWNER TO' => {
|
||||
regexp => qr/^ALTER TABLE test_third_table OWNER TO .*;/m,
|
||||
regexp => qr/^ALTER TABLE dump_test_second_schema.test_third_table OWNER TO .*;/m,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
clean => 1,
|
||||
@ -623,7 +623,7 @@ my %tests = (
|
||||
create_order => 36,
|
||||
create_sql => 'COMMENT ON TABLE dump_test.test_table
|
||||
IS \'comment on table\';',
|
||||
regexp => qr/^COMMENT ON TABLE test_table IS 'comment on table';/m,
|
||||
regexp => qr/^COMMENT ON TABLE dump_test.test_table IS 'comment on table';/m,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
clean => 1,
|
||||
@ -646,7 +646,7 @@ my %tests = (
|
||||
create_sql => 'COMMENT ON COLUMN dump_test.test_table.col1
|
||||
IS \'comment on column\';',
|
||||
regexp => qr/^
|
||||
\QCOMMENT ON COLUMN test_table.col1 IS 'comment on column';\E
|
||||
\QCOMMENT ON COLUMN dump_test.test_table.col1 IS 'comment on column';\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -670,7 +670,7 @@ my %tests = (
|
||||
create_sql => 'COMMENT ON COLUMN dump_test.composite.f1
|
||||
IS \'comment on column of type\';',
|
||||
regexp => qr/^
|
||||
\QCOMMENT ON COLUMN composite.f1 IS 'comment on column of type';\E
|
||||
\QCOMMENT ON COLUMN dump_test.composite.f1 IS 'comment on column of type';\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -706,7 +706,7 @@ my %tests = (
|
||||
create_sql => 'INSERT INTO dump_test.test_table (col1) '
|
||||
. 'SELECT generate_series FROM generate_series(1,9);',
|
||||
regexp => qr/^
|
||||
\QCOPY test_table (col1) FROM stdin;\E
|
||||
\QCOPY dump_test.test_table (col1) FROM stdin;\E
|
||||
\n(?:\d\n){9}\\\.\n
|
||||
/xm,
|
||||
like => {
|
||||
@ -731,7 +731,7 @@ my %tests = (
|
||||
create_sql => 'INSERT INTO dump_test.fk_reference_test_table (col1) '
|
||||
. 'SELECT generate_series FROM generate_series(1,5);',
|
||||
regexp => qr/^
|
||||
\QCOPY fk_reference_test_table (col1) FROM stdin;\E
|
||||
\QCOPY dump_test.fk_reference_test_table (col1) FROM stdin;\E
|
||||
\n(?:\d\n){5}\\\.\n
|
||||
/xm,
|
||||
like => {
|
||||
@ -753,9 +753,9 @@ my %tests = (
|
||||
only_dump_test_table => 1, }, },
|
||||
'COPY fk_reference_test_table second' => {
|
||||
regexp => qr/^
|
||||
\QCOPY test_table (col1) FROM stdin;\E
|
||||
\QCOPY dump_test.test_table (col1) FROM stdin;\E
|
||||
\n(?:\d\n){9}\\\.\n.*
|
||||
\QCOPY fk_reference_test_table (col1) FROM stdin;\E
|
||||
\QCOPY dump_test.fk_reference_test_table (col1) FROM stdin;\E
|
||||
\n(?:\d\n){5}\\\.\n
|
||||
/xms,
|
||||
like => { data_only => 1, },
|
||||
@ -769,7 +769,7 @@ my %tests = (
|
||||
. 'SELECT generate_series, generate_series::text '
|
||||
. 'FROM generate_series(1,9);',
|
||||
regexp => qr/^
|
||||
\QCOPY test_second_table (col1, col2) FROM stdin;\E
|
||||
\QCOPY dump_test.test_second_table (col1, col2) FROM stdin;\E
|
||||
\n(?:\d\t\d\n){9}\\\.\n
|
||||
/xm,
|
||||
like => {
|
||||
@ -795,7 +795,7 @@ my %tests = (
|
||||
'INSERT INTO dump_test_second_schema.test_third_table (col1) '
|
||||
. 'SELECT generate_series FROM generate_series(1,9);',
|
||||
regexp => qr/^
|
||||
\QCOPY test_third_table (col1) FROM stdin;\E
|
||||
\QCOPY dump_test_second_schema.test_third_table (col1) FROM stdin;\E
|
||||
\n(?:\d\n){9}\\\.\n
|
||||
/xm,
|
||||
like => {
|
||||
@ -817,7 +817,7 @@ my %tests = (
|
||||
test_schema_plus_blobs => 1, }, },
|
||||
'INSERT INTO test_table' => {
|
||||
regexp => qr/^
|
||||
(?:INSERT\ INTO\ test_table\ \(col1\)\ VALUES\ \(\d\);\n){9}
|
||||
(?:INSERT\ INTO\ dump_test.test_table\ \(col1\)\ VALUES\ \(\d\);\n){9}
|
||||
/xm,
|
||||
like => { column_inserts => 1, },
|
||||
unlike => {
|
||||
@ -838,7 +838,7 @@ my %tests = (
|
||||
test_schema_plus_blobs => 1, }, },
|
||||
'INSERT INTO test_second_table' => {
|
||||
regexp => qr/^
|
||||
(?:INSERT\ INTO\ test_second_table\ \(col1,\ col2\)
|
||||
(?:INSERT\ INTO\ dump_test.test_second_table\ \(col1,\ col2\)
|
||||
\ VALUES\ \(\d,\ '\d'\);\n){9}/xm,
|
||||
like => { column_inserts => 1, },
|
||||
unlike => {
|
||||
@ -859,7 +859,7 @@ my %tests = (
|
||||
test_schema_plus_blobs => 1, }, },
|
||||
'INSERT INTO test_third_table' => {
|
||||
regexp => qr/^
|
||||
(?:INSERT\ INTO\ test_third_table\ \(col1\)
|
||||
(?:INSERT\ INTO\ dump_test_second_schema.test_third_table\ \(col1\)
|
||||
\ VALUES\ \(\d\);\n){9}/xm,
|
||||
like => { column_inserts => 1, },
|
||||
unlike => {
|
||||
@ -1024,7 +1024,7 @@ my %tests = (
|
||||
initcond1 = \'{0,0}\'
|
||||
);',
|
||||
regexp => qr/^
|
||||
\QCREATE AGGREGATE newavg(integer) (\E
|
||||
\QCREATE AGGREGATE dump_test.newavg(integer) (\E
|
||||
\n\s+\QSFUNC = int4_avg_accum,\E
|
||||
\n\s+\QSTYPE = bigint[],\E
|
||||
\n\s+\QINITCOND = '{0,0}',\E
|
||||
@ -1057,7 +1057,7 @@ my %tests = (
|
||||
CHECK(VALUE ~ \'^\d{5}$\' OR
|
||||
VALUE ~ \'^\d{5}-\d{4}$\');',
|
||||
regexp => qr/^
|
||||
\QCREATE DOMAIN us_postal_code AS text\E
|
||||
\QCREATE DOMAIN dump_test.us_postal_code AS text\E
|
||||
\n\s+
|
||||
\QCONSTRAINT us_postal_code_check CHECK \E
|
||||
\Q(((VALUE ~ '^\d{5}\E
|
||||
@ -1091,7 +1091,7 @@ my %tests = (
|
||||
RETURNS LANGUAGE_HANDLER AS \'$libdir/plpgsql\',
|
||||
\'plpgsql_call_handler\' LANGUAGE C;',
|
||||
regexp => qr/^
|
||||
\QCREATE FUNCTION pltestlang_call_handler() \E
|
||||
\QCREATE FUNCTION dump_test.pltestlang_call_handler() \E
|
||||
\QRETURNS language_handler\E
|
||||
\n\s+\QLANGUAGE c\E
|
||||
\n\s+AS\ \'\$
|
||||
@ -1124,7 +1124,7 @@ my %tests = (
|
||||
RETURNS trigger LANGUAGE plpgsql
|
||||
AS $$ BEGIN RETURN NULL; END;$$;',
|
||||
regexp => qr/^
|
||||
\QCREATE FUNCTION trigger_func() RETURNS trigger\E
|
||||
\QCREATE FUNCTION dump_test.trigger_func() RETURNS trigger\E
|
||||
\n\s+\QLANGUAGE plpgsql\E
|
||||
\n\s+AS\ \$\$
|
||||
\Q BEGIN RETURN NULL; END;\E
|
||||
@ -1156,7 +1156,7 @@ my %tests = (
|
||||
RETURNS event_trigger LANGUAGE plpgsql
|
||||
AS $$ BEGIN RETURN; END;$$;',
|
||||
regexp => qr/^
|
||||
\QCREATE FUNCTION event_trigger_func() RETURNS event_trigger\E
|
||||
\QCREATE FUNCTION dump_test.event_trigger_func() RETURNS event_trigger\E
|
||||
\n\s+\QLANGUAGE plpgsql\E
|
||||
\n\s+AS\ \$\$
|
||||
\Q BEGIN RETURN; END;\E
|
||||
@ -1220,9 +1220,9 @@ my %tests = (
|
||||
FOR EACH ROW WHEN (NEW.col1 > 10)
|
||||
EXECUTE PROCEDURE dump_test.trigger_func();',
|
||||
regexp => qr/^
|
||||
\QCREATE TRIGGER test_trigger BEFORE INSERT ON test_table \E
|
||||
\QCREATE TRIGGER test_trigger BEFORE INSERT ON dump_test.test_table \E
|
||||
\QFOR EACH ROW WHEN ((new.col1 > 10)) \E
|
||||
\QEXECUTE PROCEDURE trigger_func();\E
|
||||
\QEXECUTE PROCEDURE dump_test.trigger_func();\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -1250,7 +1250,7 @@ my %tests = (
|
||||
create_sql => 'CREATE TYPE dump_test.planets
|
||||
AS ENUM ( \'venus\', \'earth\', \'mars\' );',
|
||||
regexp => qr/^
|
||||
\QCREATE TYPE planets AS ENUM (\E
|
||||
\QCREATE TYPE dump_test.planets AS ENUM (\E
|
||||
\n\s+'venus',
|
||||
\n\s+'earth',
|
||||
\n\s+'mars'
|
||||
@ -1277,7 +1277,7 @@ my %tests = (
|
||||
section_post_data => 1, }, },
|
||||
'CREATE TYPE dump_test.planets AS ENUM pg_upgrade' => {
|
||||
regexp => qr/^
|
||||
\QCREATE TYPE planets AS ENUM (\E
|
||||
\QCREATE TYPE dump_test.planets AS ENUM (\E
|
||||
\n\);.*^
|
||||
\QALTER TYPE dump_test.planets ADD VALUE 'venus';\E
|
||||
\n.*^
|
||||
@ -1310,7 +1310,7 @@ my %tests = (
|
||||
create_sql => 'CREATE TYPE dump_test.textrange
|
||||
AS RANGE (subtype=text, collation="C");',
|
||||
regexp => qr/^
|
||||
\QCREATE TYPE textrange AS RANGE (\E
|
||||
\QCREATE TYPE dump_test.textrange AS RANGE (\E
|
||||
\n\s+\Qsubtype = text,\E
|
||||
\n\s+\Qcollation = pg_catalog."C"\E
|
||||
\n\);/xm,
|
||||
@ -1337,7 +1337,7 @@ my %tests = (
|
||||
'CREATE TYPE dump_test.int42' => {
|
||||
create_order => 39,
|
||||
create_sql => 'CREATE TYPE dump_test.int42;',
|
||||
regexp => qr/^CREATE TYPE int42;/m,
|
||||
regexp => qr/^CREATE TYPE dump_test.int42;/m,
|
||||
like => {
|
||||
clean => 1,
|
||||
clean_if_exists => 1,
|
||||
@ -1364,7 +1364,7 @@ my %tests = (
|
||||
RETURNS dump_test.int42 AS \'int4in\'
|
||||
LANGUAGE internal STRICT IMMUTABLE;',
|
||||
regexp => qr/^
|
||||
\QCREATE FUNCTION int42_in(cstring) RETURNS int42\E
|
||||
\QCREATE FUNCTION dump_test.int42_in(cstring) RETURNS dump_test.int42\E
|
||||
\n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
|
||||
\n\s+AS\ \$\$int4in\$\$;
|
||||
/xm,
|
||||
@ -1395,7 +1395,7 @@ my %tests = (
|
||||
RETURNS cstring AS \'int4out\'
|
||||
LANGUAGE internal STRICT IMMUTABLE;',
|
||||
regexp => qr/^
|
||||
\QCREATE FUNCTION int42_out(int42) RETURNS cstring\E
|
||||
\QCREATE FUNCTION dump_test.int42_out(dump_test.int42) RETURNS cstring\E
|
||||
\n\s+\QLANGUAGE internal IMMUTABLE STRICT\E
|
||||
\n\s+AS\ \$\$int4out\$\$;
|
||||
/xm,
|
||||
@ -1430,10 +1430,10 @@ my %tests = (
|
||||
default = 42,
|
||||
passedbyvalue);',
|
||||
regexp => qr/^
|
||||
\QCREATE TYPE int42 (\E
|
||||
\QCREATE TYPE dump_test.int42 (\E
|
||||
\n\s+\QINTERNALLENGTH = 4,\E
|
||||
\n\s+\QINPUT = int42_in,\E
|
||||
\n\s+\QOUTPUT = int42_out,\E
|
||||
\n\s+\QINPUT = dump_test.int42_in,\E
|
||||
\n\s+\QOUTPUT = dump_test.int42_out,\E
|
||||
\n\s+\QDEFAULT = '42',\E
|
||||
\n\s+\QALIGNMENT = int4,\E
|
||||
\n\s+\QSTORAGE = plain,\E
|
||||
@ -1466,9 +1466,9 @@ my %tests = (
|
||||
f2 dump_test.int42
|
||||
);',
|
||||
regexp => qr/^
|
||||
\QCREATE TYPE composite AS (\E
|
||||
\QCREATE TYPE dump_test.composite AS (\E
|
||||
\n\s+\Qf1 integer,\E
|
||||
\n\s+\Qf2 int42\E
|
||||
\n\s+\Qf2 dump_test.int42\E
|
||||
\n\);
|
||||
/xm,
|
||||
like => {
|
||||
@ -1572,7 +1572,7 @@ my %tests = (
|
||||
HANDLER dump_test.pltestlang_call_handler;',
|
||||
regexp => qr/^
|
||||
\QCREATE PROCEDURAL LANGUAGE pltestlang \E
|
||||
\QHANDLER pltestlang_call_handler;\E
|
||||
\QHANDLER dump_test.pltestlang_call_handler;\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -1600,9 +1600,9 @@ my %tests = (
|
||||
create_sql => 'CREATE MATERIALIZED VIEW dump_test.matview (col1) AS
|
||||
SELECT * FROM dump_test.test_table;',
|
||||
regexp => qr/^
|
||||
\QCREATE MATERIALIZED VIEW matview AS\E
|
||||
\QCREATE MATERIALIZED VIEW dump_test.matview AS\E
|
||||
\n\s+\QSELECT test_table.col1\E
|
||||
\n\s+\QFROM test_table\E
|
||||
\n\s+\QFROM dump_test.test_table\E
|
||||
\n\s+\QWITH NO DATA;\E
|
||||
/xm,
|
||||
like => {
|
||||
@ -1632,9 +1632,9 @@ my %tests = (
|
||||
dump_test.matview_second (col1) AS
|
||||
SELECT * FROM dump_test.matview;',
|
||||
regexp => qr/^
|
||||
\QCREATE MATERIALIZED VIEW matview_second AS\E
|
||||
\QCREATE MATERIALIZED VIEW dump_test.matview_second AS\E
|
||||
\n\s+\QSELECT matview.col1\E
|
||||
\n\s+\QFROM matview\E
|
||||
\n\s+\QFROM dump_test.matview\E
|
||||
\n\s+\QWITH NO DATA;\E
|
||||
/xm,
|
||||
like => {
|
||||
@ -1664,7 +1664,7 @@ my %tests = (
|
||||
USING (true)
|
||||
WITH CHECK (true);',
|
||||
regexp => qr/^
|
||||
\QCREATE POLICY p1 ON test_table FOR ALL TO PUBLIC \E
|
||||
\QCREATE POLICY p1 ON dump_test.test_table FOR ALL TO PUBLIC \E
|
||||
\QUSING (true) WITH CHECK (true);\E
|
||||
/xm,
|
||||
like => {
|
||||
@ -1693,7 +1693,7 @@ my %tests = (
|
||||
create_sql => 'CREATE POLICY p2 ON dump_test.test_table
|
||||
FOR SELECT TO regress_dump_test_role USING (true);',
|
||||
regexp => qr/^
|
||||
\QCREATE POLICY p2 ON test_table FOR SELECT TO regress_dump_test_role \E
|
||||
\QCREATE POLICY p2 ON dump_test.test_table FOR SELECT TO regress_dump_test_role \E
|
||||
\QUSING (true);\E
|
||||
/xm,
|
||||
like => {
|
||||
@ -1722,7 +1722,7 @@ my %tests = (
|
||||
create_sql => 'CREATE POLICY p3 ON dump_test.test_table
|
||||
FOR INSERT TO regress_dump_test_role WITH CHECK (true);',
|
||||
regexp => qr/^
|
||||
\QCREATE POLICY p3 ON test_table FOR INSERT \E
|
||||
\QCREATE POLICY p3 ON dump_test.test_table FOR INSERT \E
|
||||
\QTO regress_dump_test_role WITH CHECK (true);\E
|
||||
/xm,
|
||||
like => {
|
||||
@ -1751,7 +1751,7 @@ my %tests = (
|
||||
create_sql => 'CREATE POLICY p4 ON dump_test.test_table FOR UPDATE
|
||||
TO regress_dump_test_role USING (true) WITH CHECK (true);',
|
||||
regexp => qr/^
|
||||
\QCREATE POLICY p4 ON test_table FOR UPDATE TO regress_dump_test_role \E
|
||||
\QCREATE POLICY p4 ON dump_test.test_table FOR UPDATE TO regress_dump_test_role \E
|
||||
\QUSING (true) WITH CHECK (true);\E
|
||||
/xm,
|
||||
like => {
|
||||
@ -1780,7 +1780,7 @@ my %tests = (
|
||||
create_sql => 'CREATE POLICY p5 ON dump_test.test_table
|
||||
FOR DELETE TO regress_dump_test_role USING (true);',
|
||||
regexp => qr/^
|
||||
\QCREATE POLICY p5 ON test_table FOR DELETE \E
|
||||
\QCREATE POLICY p5 ON dump_test.test_table FOR DELETE \E
|
||||
\QTO regress_dump_test_role USING (true);\E
|
||||
/xm,
|
||||
like => {
|
||||
@ -1861,7 +1861,7 @@ my %tests = (
|
||||
CHECK (col1 <= 1000)
|
||||
);',
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE test_table (\E
|
||||
\QCREATE TABLE dump_test.test_table (\E
|
||||
\n\s+\Qcol1 integer NOT NULL,\E
|
||||
\n\s+\QCONSTRAINT test_table_col1_check CHECK \E
|
||||
\Q((col1 <= 1000))\E
|
||||
@ -1893,7 +1893,7 @@ my %tests = (
|
||||
col1 int primary key references dump_test.test_table
|
||||
);',
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE fk_reference_test_table (\E
|
||||
\QCREATE TABLE dump_test.fk_reference_test_table (\E
|
||||
\n\s+\Qcol1 integer NOT NULL\E
|
||||
\n\);
|
||||
/xm,
|
||||
@ -1925,7 +1925,7 @@ my %tests = (
|
||||
col2 text
|
||||
);',
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE test_second_table (\E
|
||||
\QCREATE TABLE dump_test.test_second_table (\E
|
||||
\n\s+\Qcol1 integer,\E
|
||||
\n\s+\Qcol2 text\E
|
||||
\n\);
|
||||
@ -1957,7 +1957,7 @@ my %tests = (
|
||||
col1 serial
|
||||
);',
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE test_third_table (\E
|
||||
\QCREATE TABLE dump_test_second_schema.test_third_table (\E
|
||||
\n\s+\Qcol1 integer NOT NULL\E
|
||||
\n\);
|
||||
/xm,
|
||||
@ -1984,7 +1984,7 @@ my %tests = (
|
||||
test_schema_plus_blobs => 1, }, },
|
||||
'CREATE SEQUENCE test_table_col1_seq' => {
|
||||
regexp => qr/^
|
||||
\QCREATE SEQUENCE test_table_col1_seq\E
|
||||
\QCREATE SEQUENCE dump_test.test_table_col1_seq\E
|
||||
\n\s+\QSTART WITH 1\E
|
||||
\n\s+\QINCREMENT BY 1\E
|
||||
\n\s+\QNO MINVALUE\E
|
||||
@ -2014,7 +2014,7 @@ my %tests = (
|
||||
section_post_data => 1, }, },
|
||||
'CREATE SEQUENCE test_third_table_col1_seq' => {
|
||||
regexp => qr/^
|
||||
\QCREATE SEQUENCE test_third_table_col1_seq\E
|
||||
\QCREATE SEQUENCE dump_test_second_schema.test_third_table_col1_seq\E
|
||||
\n\s+\QSTART WITH 1\E
|
||||
\n\s+\QINCREMENT BY 1\E
|
||||
\n\s+\QNO MINVALUE\E
|
||||
@ -2048,7 +2048,7 @@ my %tests = (
|
||||
ON dump_test_second_schema.test_third_table (col1);',
|
||||
regexp => qr/^
|
||||
\QCREATE UNIQUE INDEX test_third_table_idx \E
|
||||
\QON test_third_table USING btree (col1);\E
|
||||
\QON dump_test_second_schema.test_third_table USING btree (col1);\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -2239,7 +2239,7 @@ my %tests = (
|
||||
create_sql => 'GRANT SELECT ON TABLE dump_test.test_table
|
||||
TO regress_dump_test_role;',
|
||||
regexp =>
|
||||
qr/^GRANT SELECT ON TABLE test_table TO regress_dump_test_role;/m,
|
||||
qr/^GRANT SELECT ON TABLE dump_test.test_table TO regress_dump_test_role;/m,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
clean => 1,
|
||||
@ -2264,7 +2264,7 @@ my %tests = (
|
||||
TABLE dump_test_second_schema.test_third_table
|
||||
TO regress_dump_test_role;',
|
||||
regexp =>
|
||||
qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
|
||||
qr/^GRANT SELECT ON TABLE dump_test_second_schema.test_third_table TO regress_dump_test_role;/m,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
clean => 1,
|
||||
@ -2289,7 +2289,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
|
||||
dump_test_second_schema.test_third_table_col1_seq
|
||||
TO regress_dump_test_role;',
|
||||
regexp => qr/^
|
||||
\QGRANT ALL ON SEQUENCE test_third_table_col1_seq TO regress_dump_test_role;\E
|
||||
\QGRANT ALL ON SEQUENCE dump_test_second_schema.test_third_table_col1_seq TO regress_dump_test_role;\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -2315,7 +2315,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
|
||||
'GRANT INSERT (col1) ON TABLE dump_test.test_second_table
|
||||
TO regress_dump_test_role;',
|
||||
regexp => qr/^
|
||||
\QGRANT INSERT(col1) ON TABLE test_second_table TO regress_dump_test_role;\E
|
||||
\QGRANT INSERT(col1) ON TABLE dump_test.test_second_table TO regress_dump_test_role;\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -2340,7 +2340,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
|
||||
create_sql => 'GRANT EXECUTE ON FUNCTION pg_sleep(float8)
|
||||
TO regress_dump_test_role;',
|
||||
regexp => qr/^
|
||||
\QGRANT ALL ON FUNCTION pg_sleep(double precision) TO regress_dump_test_role;\E
|
||||
\QGRANT ALL ON FUNCTION pg_catalog.pg_sleep(double precision) TO regress_dump_test_role;\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -2395,37 +2395,37 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
|
||||
proacl
|
||||
) ON TABLE pg_proc TO public;',
|
||||
regexp => qr/
|
||||
\QGRANT SELECT(tableoid) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(oid) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proname) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(pronamespace) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proowner) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prolang) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(procost) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prorows) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(provariadic) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(protransform) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proisagg) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proiswindow) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prosecdef) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proleakproof) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proisstrict) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proretset) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(provolatile) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proparallel) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(pronargs) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(pronargdefaults) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prorettype) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proargtypes) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proallargtypes) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proargmodes) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proargnames) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proargdefaults) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(protrftypes) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prosrc) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(probin) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proconfig) ON TABLE pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proacl) ON TABLE pg_proc TO PUBLIC;\E/xms,
|
||||
\QGRANT SELECT(tableoid) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(oid) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proname) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(pronamespace) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proowner) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prolang) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(procost) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prorows) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(provariadic) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(protransform) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proisagg) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proiswindow) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prosecdef) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proleakproof) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proisstrict) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proretset) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(provolatile) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proparallel) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(pronargs) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(pronargdefaults) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prorettype) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proargtypes) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proallargtypes) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proargmodes) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proargnames) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proargdefaults) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(protrftypes) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(prosrc) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(probin) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proconfig) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E\n.*
|
||||
\QGRANT SELECT(proacl) ON TABLE pg_catalog.pg_proc TO PUBLIC;\E/xms,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
clean => 1,
|
||||
@ -2474,7 +2474,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
|
||||
no_privs => 1,
|
||||
section_data => 1, }, },
|
||||
'REFRESH MATERIALIZED VIEW matview' => {
|
||||
regexp => qr/^REFRESH MATERIALIZED VIEW matview;/m,
|
||||
regexp => qr/^REFRESH MATERIALIZED VIEW dump_test.matview;/m,
|
||||
like => {
|
||||
clean => 1,
|
||||
clean_if_exists => 1,
|
||||
@ -2497,9 +2497,9 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
|
||||
section_pre_data => 1, }, },
|
||||
'REFRESH MATERIALIZED VIEW matview_second' => {
|
||||
regexp => qr/^
|
||||
\QREFRESH MATERIALIZED VIEW matview;\E
|
||||
\QREFRESH MATERIALIZED VIEW dump_test.matview;\E
|
||||
\n.*
|
||||
\QREFRESH MATERIALIZED VIEW matview_second;\E
|
||||
\QREFRESH MATERIALIZED VIEW dump_test.matview_second;\E
|
||||
/xms,
|
||||
like => {
|
||||
clean => 1,
|
||||
@ -2549,7 +2549,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
|
||||
create_sql => 'REVOKE EXECUTE ON FUNCTION pg_sleep(float8)
|
||||
FROM public;',
|
||||
regexp => qr/^
|
||||
\QREVOKE ALL ON FUNCTION pg_sleep(double precision) FROM PUBLIC;\E
|
||||
\QREVOKE ALL ON FUNCTION pg_catalog.pg_sleep(double precision) FROM PUBLIC;\E
|
||||
/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -2571,7 +2571,7 @@ qr/^GRANT SELECT ON TABLE test_third_table TO regress_dump_test_role;/m,
|
||||
'REVOKE SELECT ON TABLE pg_proc FROM public' => {
|
||||
create_order => 45,
|
||||
create_sql => 'REVOKE SELECT ON TABLE pg_proc FROM public;',
|
||||
regexp => qr/^REVOKE SELECT ON TABLE pg_proc FROM PUBLIC;/m,
|
||||
regexp => qr/^REVOKE SELECT ON TABLE pg_catalog.pg_proc FROM PUBLIC;/m,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
clean => 1,
|
||||
|
@ -184,7 +184,7 @@ my %tests = (
|
||||
create_sql =>
|
||||
'ALTER EXTENSION test_pg_dump ADD TABLE regress_pg_dump_table_added;',
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE regress_pg_dump_table_added (\E
|
||||
\QCREATE TABLE public.regress_pg_dump_table_added (\E
|
||||
\n\s+\Qcol1 integer NOT NULL,\E
|
||||
\n\s+\Qcol2 integer\E
|
||||
\n\);\n/xm,
|
||||
@ -240,7 +240,7 @@ my %tests = (
|
||||
|
||||
'CREATE SEQUENCE regress_pg_dump_table_col1_seq' => {
|
||||
regexp => qr/^
|
||||
\QCREATE SEQUENCE regress_pg_dump_table_col1_seq\E
|
||||
\QCREATE SEQUENCE public.regress_pg_dump_table_col1_seq\E
|
||||
\n\s+\QSTART WITH 1\E
|
||||
\n\s+\QINCREMENT BY 1\E
|
||||
\n\s+\QNO MINVALUE\E
|
||||
@ -265,7 +265,7 @@ my %tests = (
|
||||
create_sql =>
|
||||
'CREATE TABLE regress_pg_dump_table_added (col1 int not null, col2 int);',
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE regress_pg_dump_table_added (\E
|
||||
\QCREATE TABLE public.regress_pg_dump_table_added (\E
|
||||
\n\s+\Qcol1 integer NOT NULL,\E
|
||||
\n\s+\Qcol2 integer\E
|
||||
\n\);\n/xm,
|
||||
@ -284,7 +284,7 @@ my %tests = (
|
||||
|
||||
'CREATE SEQUENCE regress_pg_dump_seq' => {
|
||||
regexp => qr/^
|
||||
\QCREATE SEQUENCE regress_pg_dump_seq\E
|
||||
\QCREATE SEQUENCE public.regress_pg_dump_seq\E
|
||||
\n\s+\QSTART WITH 1\E
|
||||
\n\s+\QINCREMENT BY 1\E
|
||||
\n\s+\QNO MINVALUE\E
|
||||
@ -308,7 +308,7 @@ my %tests = (
|
||||
create_order => 6,
|
||||
create_sql => qq{SELECT nextval('regress_seq_dumpable');},
|
||||
regexp => qr/^
|
||||
\QSELECT pg_catalog.setval('regress_seq_dumpable', 1, true);\E
|
||||
\QSELECT pg_catalog.setval('public.regress_seq_dumpable', 1, true);\E
|
||||
\n/xm,
|
||||
like => {
|
||||
clean => 1,
|
||||
@ -326,7 +326,7 @@ my %tests = (
|
||||
|
||||
'CREATE TABLE regress_pg_dump_table' => {
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE regress_pg_dump_table (\E
|
||||
\QCREATE TABLE public.regress_pg_dump_table (\E
|
||||
\n\s+\Qcol1 integer NOT NULL,\E
|
||||
\n\s+\Qcol2 integer\E
|
||||
\n\);\n/xm,
|
||||
@ -384,7 +384,7 @@ my %tests = (
|
||||
create_sql =>
|
||||
'GRANT SELECT ON regress_pg_dump_table_added TO regress_dump_test_role;',
|
||||
regexp => qr/^
|
||||
\QGRANT SELECT ON TABLE regress_pg_dump_table_added TO regress_dump_test_role;\E
|
||||
\QGRANT SELECT ON TABLE public.regress_pg_dump_table_added TO regress_dump_test_role;\E
|
||||
\n/xm,
|
||||
like => { binary_upgrade => 1, },
|
||||
unlike => {
|
||||
@ -404,7 +404,7 @@ my %tests = (
|
||||
create_sql =>
|
||||
'REVOKE SELECT ON regress_pg_dump_table_added FROM regress_dump_test_role;',
|
||||
regexp => qr/^
|
||||
\QREVOKE SELECT ON TABLE regress_pg_dump_table_added FROM regress_dump_test_role;\E
|
||||
\QREVOKE SELECT ON TABLE public.regress_pg_dump_table_added FROM regress_dump_test_role;\E
|
||||
\n/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -423,7 +423,7 @@ my %tests = (
|
||||
'GRANT SELECT ON TABLE regress_pg_dump_table' => {
|
||||
regexp => qr/^
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
|
||||
\QGRANT SELECT ON TABLE regress_pg_dump_table TO regress_dump_test_role;\E\n
|
||||
\QGRANT SELECT ON TABLE public.regress_pg_dump_table TO regress_dump_test_role;\E\n
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
|
||||
\n/xms,
|
||||
like => { binary_upgrade => 1, },
|
||||
@ -442,7 +442,7 @@ my %tests = (
|
||||
'GRANT SELECT(col1) ON regress_pg_dump_table' => {
|
||||
regexp => qr/^
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
|
||||
\QGRANT SELECT(col1) ON TABLE regress_pg_dump_table TO PUBLIC;\E\n
|
||||
\QGRANT SELECT(col1) ON TABLE public.regress_pg_dump_table TO PUBLIC;\E\n
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
|
||||
\n/xms,
|
||||
like => { binary_upgrade => 1, },
|
||||
@ -464,7 +464,7 @@ my %tests = (
|
||||
create_sql => 'GRANT SELECT(col2) ON regress_pg_dump_table
|
||||
TO regress_dump_test_role;',
|
||||
regexp => qr/^
|
||||
\QGRANT SELECT(col2) ON TABLE regress_pg_dump_table TO regress_dump_test_role;\E
|
||||
\QGRANT SELECT(col2) ON TABLE public.regress_pg_dump_table TO regress_dump_test_role;\E
|
||||
\n/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -486,7 +486,7 @@ my %tests = (
|
||||
create_sql => 'GRANT USAGE ON SEQUENCE regress_pg_dump_table_col1_seq
|
||||
TO regress_dump_test_role;',
|
||||
regexp => qr/^
|
||||
\QGRANT USAGE ON SEQUENCE regress_pg_dump_table_col1_seq TO regress_dump_test_role;\E
|
||||
\QGRANT USAGE ON SEQUENCE public.regress_pg_dump_table_col1_seq TO regress_dump_test_role;\E
|
||||
\n/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -504,7 +504,7 @@ my %tests = (
|
||||
|
||||
'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => {
|
||||
regexp => qr/^
|
||||
\QGRANT USAGE ON SEQUENCE regress_pg_dump_seq TO regress_dump_test_role;\E
|
||||
\QGRANT USAGE ON SEQUENCE public.regress_pg_dump_seq TO regress_dump_test_role;\E
|
||||
\n/xm,
|
||||
like => { binary_upgrade => 1, },
|
||||
unlike => {
|
||||
@ -524,7 +524,7 @@ my %tests = (
|
||||
create_sql => 'REVOKE SELECT(col1) ON regress_pg_dump_table
|
||||
FROM PUBLIC;',
|
||||
regexp => qr/^
|
||||
\QREVOKE SELECT(col1) ON TABLE regress_pg_dump_table FROM PUBLIC;\E
|
||||
\QREVOKE SELECT(col1) ON TABLE public.regress_pg_dump_table FROM PUBLIC;\E
|
||||
\n/xm,
|
||||
like => {
|
||||
binary_upgrade => 1,
|
||||
@ -543,7 +543,7 @@ my %tests = (
|
||||
# Objects included in extension part of a schema created by this extension */
|
||||
'CREATE TABLE regress_pg_dump_schema.test_table' => {
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE test_table (\E
|
||||
\QCREATE TABLE regress_pg_dump_schema.test_table (\E
|
||||
\n\s+\Qcol1 integer,\E
|
||||
\n\s+\Qcol2 integer\E
|
||||
\n\);\n/xm,
|
||||
@ -563,7 +563,7 @@ my %tests = (
|
||||
'GRANT SELECT ON regress_pg_dump_schema.test_table' => {
|
||||
regexp => qr/^
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
|
||||
\QGRANT SELECT ON TABLE test_table TO regress_dump_test_role;\E\n
|
||||
\QGRANT SELECT ON TABLE regress_pg_dump_schema.test_table TO regress_dump_test_role;\E\n
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
|
||||
\n/xms,
|
||||
like => { binary_upgrade => 1, },
|
||||
@ -581,7 +581,7 @@ my %tests = (
|
||||
|
||||
'CREATE SEQUENCE regress_pg_dump_schema.test_seq' => {
|
||||
regexp => qr/^
|
||||
\QCREATE SEQUENCE test_seq\E
|
||||
\QCREATE SEQUENCE regress_pg_dump_schema.test_seq\E
|
||||
\n\s+\QSTART WITH 1\E
|
||||
\n\s+\QINCREMENT BY 1\E
|
||||
\n\s+\QNO MINVALUE\E
|
||||
@ -604,7 +604,7 @@ my %tests = (
|
||||
'GRANT USAGE ON regress_pg_dump_schema.test_seq' => {
|
||||
regexp => qr/^
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
|
||||
\QGRANT USAGE ON SEQUENCE test_seq TO regress_dump_test_role;\E\n
|
||||
\QGRANT USAGE ON SEQUENCE regress_pg_dump_schema.test_seq TO regress_dump_test_role;\E\n
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
|
||||
\n/xms,
|
||||
like => { binary_upgrade => 1, },
|
||||
@ -622,7 +622,7 @@ my %tests = (
|
||||
|
||||
'CREATE TYPE regress_pg_dump_schema.test_type' => {
|
||||
regexp => qr/^
|
||||
\QCREATE TYPE test_type AS (\E
|
||||
\QCREATE TYPE regress_pg_dump_schema.test_type AS (\E
|
||||
\n\s+\Qcol1 integer\E
|
||||
\n\);\n/xm,
|
||||
like => { binary_upgrade => 1, },
|
||||
@ -641,7 +641,7 @@ my %tests = (
|
||||
'GRANT USAGE ON regress_pg_dump_schema.test_type' => {
|
||||
regexp => qr/^
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
|
||||
\QGRANT ALL ON TYPE test_type TO regress_dump_test_role;\E\n
|
||||
\QGRANT ALL ON TYPE regress_pg_dump_schema.test_type TO regress_dump_test_role;\E\n
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
|
||||
\n/xms,
|
||||
like => { binary_upgrade => 1, },
|
||||
@ -659,7 +659,7 @@ my %tests = (
|
||||
|
||||
'CREATE FUNCTION regress_pg_dump_schema.test_func' => {
|
||||
regexp => qr/^
|
||||
\QCREATE FUNCTION test_func() RETURNS integer\E
|
||||
\QCREATE FUNCTION regress_pg_dump_schema.test_func() RETURNS integer\E
|
||||
\n\s+\QLANGUAGE sql\E
|
||||
\n/xm,
|
||||
like => { binary_upgrade => 1, },
|
||||
@ -678,7 +678,7 @@ my %tests = (
|
||||
'GRANT ALL ON regress_pg_dump_schema.test_func' => {
|
||||
regexp => qr/^
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
|
||||
\QGRANT ALL ON FUNCTION test_func() TO regress_dump_test_role;\E\n
|
||||
\QGRANT ALL ON FUNCTION regress_pg_dump_schema.test_func() TO regress_dump_test_role;\E\n
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
|
||||
\n/xms,
|
||||
like => { binary_upgrade => 1, },
|
||||
@ -696,7 +696,7 @@ my %tests = (
|
||||
|
||||
'CREATE AGGREGATE regress_pg_dump_schema.test_agg' => {
|
||||
regexp => qr/^
|
||||
\QCREATE AGGREGATE test_agg(smallint) (\E
|
||||
\QCREATE AGGREGATE regress_pg_dump_schema.test_agg(smallint) (\E
|
||||
\n\s+\QSFUNC = int2_sum,\E
|
||||
\n\s+\QSTYPE = bigint\E
|
||||
\n\);\n/xm,
|
||||
@ -716,7 +716,7 @@ my %tests = (
|
||||
'GRANT ALL ON regress_pg_dump_schema.test_agg' => {
|
||||
regexp => qr/^
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
|
||||
\QGRANT ALL ON FUNCTION test_agg(smallint) TO regress_dump_test_role;\E\n
|
||||
\QGRANT ALL ON FUNCTION regress_pg_dump_schema.test_agg(smallint) TO regress_dump_test_role;\E\n
|
||||
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
|
||||
\n/xms,
|
||||
like => { binary_upgrade => 1, },
|
||||
@ -738,7 +738,7 @@ my %tests = (
|
||||
create_sql => 'CREATE TABLE regress_pg_dump_schema.external_tab
|
||||
(col1 int);',
|
||||
regexp => qr/^
|
||||
\QCREATE TABLE external_tab (\E
|
||||
\QCREATE TABLE regress_pg_dump_schema.external_tab (\E
|
||||
\n\s+\Qcol1 integer\E
|
||||
\n\);\n/xm,
|
||||
like => {
|
||||
|
@ -943,12 +943,12 @@ ERROR: collations are not supported by type integer
|
||||
LINE 1: ...ATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "C...
|
||||
^
|
||||
SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1;
|
||||
relname | pg_get_indexdef
|
||||
--------------------+-----------------------------------------------------------------------------------------------------
|
||||
collate_test1_idx1 | CREATE INDEX collate_test1_idx1 ON collate_test1 USING btree (b)
|
||||
collate_test1_idx2 | CREATE INDEX collate_test1_idx2 ON collate_test1 USING btree (b COLLATE "C")
|
||||
collate_test1_idx3 | CREATE INDEX collate_test1_idx3 ON collate_test1 USING btree (b COLLATE "C")
|
||||
collate_test1_idx4 | CREATE INDEX collate_test1_idx4 ON collate_test1 USING btree (((b || 'foo'::text)) COLLATE "POSIX")
|
||||
relname | pg_get_indexdef
|
||||
--------------------+------------------------------------------------------------------------------------------------------------
|
||||
collate_test1_idx1 | CREATE INDEX collate_test1_idx1 ON public.collate_test1 USING btree (b)
|
||||
collate_test1_idx2 | CREATE INDEX collate_test1_idx2 ON public.collate_test1 USING btree (b COLLATE "C")
|
||||
collate_test1_idx3 | CREATE INDEX collate_test1_idx3 ON public.collate_test1 USING btree (b COLLATE "C")
|
||||
collate_test1_idx4 | CREATE INDEX collate_test1_idx4 ON public.collate_test1 USING btree (((b || 'foo'::text)) COLLATE "POSIX")
|
||||
(4 rows)
|
||||
|
||||
-- schema manipulation commands
|
||||
|
@ -572,12 +572,12 @@ ERROR: collations are not supported by type integer
|
||||
LINE 1: ...ATE INDEX collate_test1_idx6 ON collate_test1 ((a COLLATE "P...
|
||||
^
|
||||
SELECT relname, pg_get_indexdef(oid) FROM pg_class WHERE relname LIKE 'collate_test%_idx%' ORDER BY 1;
|
||||
relname | pg_get_indexdef
|
||||
--------------------+-----------------------------------------------------------------------------------------------------
|
||||
collate_test1_idx1 | CREATE INDEX collate_test1_idx1 ON collate_test1 USING btree (b)
|
||||
collate_test1_idx2 | CREATE INDEX collate_test1_idx2 ON collate_test1 USING btree (b COLLATE "POSIX")
|
||||
collate_test1_idx3 | CREATE INDEX collate_test1_idx3 ON collate_test1 USING btree (b COLLATE "POSIX")
|
||||
collate_test1_idx4 | CREATE INDEX collate_test1_idx4 ON collate_test1 USING btree (((b || 'foo'::text)) COLLATE "POSIX")
|
||||
relname | pg_get_indexdef
|
||||
--------------------+-------------------------------------------------------------------------------------------------------------------
|
||||
collate_test1_idx1 | CREATE INDEX collate_test1_idx1 ON collate_tests.collate_test1 USING btree (b)
|
||||
collate_test1_idx2 | CREATE INDEX collate_test1_idx2 ON collate_tests.collate_test1 USING btree (b COLLATE "POSIX")
|
||||
collate_test1_idx3 | CREATE INDEX collate_test1_idx3 ON collate_tests.collate_test1 USING btree (b COLLATE "POSIX")
|
||||
collate_test1_idx4 | CREATE INDEX collate_test1_idx4 ON collate_tests.collate_test1 USING btree (((b || 'foo'::text)) COLLATE "POSIX")
|
||||
(4 rows)
|
||||
|
||||
-- foreign keys
|
||||
|
@ -2265,103 +2265,103 @@ toyemp| SELECT emp.name,
|
||||
SELECT tablename, rulename, definition FROM pg_rules
|
||||
ORDER BY tablename, rulename;
|
||||
pg_settings|pg_settings_n|CREATE RULE pg_settings_n AS
|
||||
ON UPDATE TO pg_settings DO INSTEAD NOTHING;
|
||||
ON UPDATE TO pg_catalog.pg_settings DO INSTEAD NOTHING;
|
||||
pg_settings|pg_settings_u|CREATE RULE pg_settings_u AS
|
||||
ON UPDATE TO pg_settings
|
||||
ON UPDATE TO pg_catalog.pg_settings
|
||||
WHERE (new.name = old.name) DO SELECT set_config(old.name, new.setting, false) AS set_config;
|
||||
rtest_emp|rtest_emp_del|CREATE RULE rtest_emp_del AS
|
||||
ON DELETE TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, action, newsal, oldsal)
|
||||
ON DELETE TO public.rtest_emp DO INSERT INTO rtest_emplog (ename, who, action, newsal, oldsal)
|
||||
VALUES (old.ename, "current_user"(), 'fired'::bpchar, '$0.00'::money, old.salary);
|
||||
rtest_emp|rtest_emp_ins|CREATE RULE rtest_emp_ins AS
|
||||
ON INSERT TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, action, newsal, oldsal)
|
||||
ON INSERT TO public.rtest_emp DO INSERT INTO rtest_emplog (ename, who, action, newsal, oldsal)
|
||||
VALUES (new.ename, "current_user"(), 'hired'::bpchar, new.salary, '$0.00'::money);
|
||||
rtest_emp|rtest_emp_upd|CREATE RULE rtest_emp_upd AS
|
||||
ON UPDATE TO rtest_emp
|
||||
ON UPDATE TO public.rtest_emp
|
||||
WHERE (new.salary <> old.salary) DO INSERT INTO rtest_emplog (ename, who, action, newsal, oldsal)
|
||||
VALUES (new.ename, "current_user"(), 'honored'::bpchar, new.salary, old.salary);
|
||||
rtest_nothn1|rtest_nothn_r1|CREATE RULE rtest_nothn_r1 AS
|
||||
ON INSERT TO rtest_nothn1
|
||||
ON INSERT TO public.rtest_nothn1
|
||||
WHERE ((new.a >= 10) AND (new.a < 20)) DO INSTEAD NOTHING;
|
||||
rtest_nothn1|rtest_nothn_r2|CREATE RULE rtest_nothn_r2 AS
|
||||
ON INSERT TO rtest_nothn1
|
||||
ON INSERT TO public.rtest_nothn1
|
||||
WHERE ((new.a >= 30) AND (new.a < 40)) DO INSTEAD NOTHING;
|
||||
rtest_nothn2|rtest_nothn_r3|CREATE RULE rtest_nothn_r3 AS
|
||||
ON INSERT TO rtest_nothn2
|
||||
ON INSERT TO public.rtest_nothn2
|
||||
WHERE (new.a >= 100) DO INSTEAD INSERT INTO rtest_nothn3 (a, b)
|
||||
VALUES (new.a, new.b);
|
||||
rtest_nothn2|rtest_nothn_r4|CREATE RULE rtest_nothn_r4 AS
|
||||
ON INSERT TO rtest_nothn2 DO INSTEAD NOTHING;
|
||||
ON INSERT TO public.rtest_nothn2 DO INSTEAD NOTHING;
|
||||
rtest_order1|rtest_order_r1|CREATE RULE rtest_order_r1 AS
|
||||
ON INSERT TO rtest_order1 DO INSTEAD INSERT INTO rtest_order2 (a, b, c)
|
||||
ON INSERT TO public.rtest_order1 DO INSTEAD INSERT INTO rtest_order2 (a, b, c)
|
||||
VALUES (new.a, nextval('rtest_seq'::regclass), 'rule 1 - this should run 1st'::text);
|
||||
rtest_order1|rtest_order_r2|CREATE RULE rtest_order_r2 AS
|
||||
ON INSERT TO rtest_order1 DO INSERT INTO rtest_order2 (a, b, c)
|
||||
ON INSERT TO public.rtest_order1 DO INSERT INTO rtest_order2 (a, b, c)
|
||||
VALUES (new.a, nextval('rtest_seq'::regclass), 'rule 2 - this should run 2nd'::text);
|
||||
rtest_order1|rtest_order_r3|CREATE RULE rtest_order_r3 AS
|
||||
ON INSERT TO rtest_order1 DO INSTEAD INSERT INTO rtest_order2 (a, b, c)
|
||||
ON INSERT TO public.rtest_order1 DO INSTEAD INSERT INTO rtest_order2 (a, b, c)
|
||||
VALUES (new.a, nextval('rtest_seq'::regclass), 'rule 3 - this should run 3rd'::text);
|
||||
rtest_order1|rtest_order_r4|CREATE RULE rtest_order_r4 AS
|
||||
ON INSERT TO rtest_order1
|
||||
ON INSERT TO public.rtest_order1
|
||||
WHERE (new.a < 100) DO INSTEAD INSERT INTO rtest_order2 (a, b, c)
|
||||
VALUES (new.a, nextval('rtest_seq'::regclass), 'rule 4 - this should run 4th'::text);
|
||||
rtest_person|rtest_pers_del|CREATE RULE rtest_pers_del AS
|
||||
ON DELETE TO rtest_person DO DELETE FROM rtest_admin
|
||||
ON DELETE TO public.rtest_person DO DELETE FROM rtest_admin
|
||||
WHERE (rtest_admin.pname = old.pname);
|
||||
rtest_person|rtest_pers_upd|CREATE RULE rtest_pers_upd AS
|
||||
ON UPDATE TO rtest_person DO UPDATE rtest_admin SET pname = new.pname
|
||||
ON UPDATE TO public.rtest_person DO UPDATE rtest_admin SET pname = new.pname
|
||||
WHERE (rtest_admin.pname = old.pname);
|
||||
rtest_system|rtest_sys_del|CREATE RULE rtest_sys_del AS
|
||||
ON DELETE TO rtest_system DO ( DELETE FROM rtest_interface
|
||||
ON DELETE TO public.rtest_system DO ( DELETE FROM rtest_interface
|
||||
WHERE (rtest_interface.sysname = old.sysname);
|
||||
DELETE FROM rtest_admin
|
||||
WHERE (rtest_admin.sysname = old.sysname);
|
||||
);
|
||||
rtest_system|rtest_sys_upd|CREATE RULE rtest_sys_upd AS
|
||||
ON UPDATE TO rtest_system DO ( UPDATE rtest_interface SET sysname = new.sysname
|
||||
ON UPDATE TO public.rtest_system DO ( UPDATE rtest_interface SET sysname = new.sysname
|
||||
WHERE (rtest_interface.sysname = old.sysname);
|
||||
UPDATE rtest_admin SET sysname = new.sysname
|
||||
WHERE (rtest_admin.sysname = old.sysname);
|
||||
);
|
||||
rtest_t4|rtest_t4_ins1|CREATE RULE rtest_t4_ins1 AS
|
||||
ON INSERT TO rtest_t4
|
||||
ON INSERT TO public.rtest_t4
|
||||
WHERE ((new.a >= 10) AND (new.a < 20)) DO INSTEAD INSERT INTO rtest_t5 (a, b)
|
||||
VALUES (new.a, new.b);
|
||||
rtest_t4|rtest_t4_ins2|CREATE RULE rtest_t4_ins2 AS
|
||||
ON INSERT TO rtest_t4
|
||||
ON INSERT TO public.rtest_t4
|
||||
WHERE ((new.a >= 20) AND (new.a < 30)) DO INSERT INTO rtest_t6 (a, b)
|
||||
VALUES (new.a, new.b);
|
||||
rtest_t5|rtest_t5_ins|CREATE RULE rtest_t5_ins AS
|
||||
ON INSERT TO rtest_t5
|
||||
ON INSERT TO public.rtest_t5
|
||||
WHERE (new.a > 15) DO INSERT INTO rtest_t7 (a, b)
|
||||
VALUES (new.a, new.b);
|
||||
rtest_t6|rtest_t6_ins|CREATE RULE rtest_t6_ins AS
|
||||
ON INSERT TO rtest_t6
|
||||
ON INSERT TO public.rtest_t6
|
||||
WHERE (new.a > 25) DO INSTEAD INSERT INTO rtest_t8 (a, b)
|
||||
VALUES (new.a, new.b);
|
||||
rtest_v1|rtest_v1_del|CREATE RULE rtest_v1_del AS
|
||||
ON DELETE TO rtest_v1 DO INSTEAD DELETE FROM rtest_t1
|
||||
ON DELETE TO public.rtest_v1 DO INSTEAD DELETE FROM rtest_t1
|
||||
WHERE (rtest_t1.a = old.a);
|
||||
rtest_v1|rtest_v1_ins|CREATE RULE rtest_v1_ins AS
|
||||
ON INSERT TO rtest_v1 DO INSTEAD INSERT INTO rtest_t1 (a, b)
|
||||
ON INSERT TO public.rtest_v1 DO INSTEAD INSERT INTO rtest_t1 (a, b)
|
||||
VALUES (new.a, new.b);
|
||||
rtest_v1|rtest_v1_upd|CREATE RULE rtest_v1_upd AS
|
||||
ON UPDATE TO rtest_v1 DO INSTEAD UPDATE rtest_t1 SET a = new.a, b = new.b
|
||||
ON UPDATE TO public.rtest_v1 DO INSTEAD UPDATE rtest_t1 SET a = new.a, b = new.b
|
||||
WHERE (rtest_t1.a = old.a);
|
||||
shoelace|shoelace_del|CREATE RULE shoelace_del AS
|
||||
ON DELETE TO shoelace DO INSTEAD DELETE FROM shoelace_data
|
||||
ON DELETE TO public.shoelace DO INSTEAD DELETE FROM shoelace_data
|
||||
WHERE (shoelace_data.sl_name = old.sl_name);
|
||||
shoelace|shoelace_ins|CREATE RULE shoelace_ins AS
|
||||
ON INSERT TO shoelace DO INSTEAD INSERT INTO shoelace_data (sl_name, sl_avail, sl_color, sl_len, sl_unit)
|
||||
ON INSERT TO public.shoelace DO INSTEAD INSERT INTO shoelace_data (sl_name, sl_avail, sl_color, sl_len, sl_unit)
|
||||
VALUES (new.sl_name, new.sl_avail, new.sl_color, new.sl_len, new.sl_unit);
|
||||
shoelace|shoelace_upd|CREATE RULE shoelace_upd AS
|
||||
ON UPDATE TO shoelace DO INSTEAD UPDATE shoelace_data SET sl_name = new.sl_name, sl_avail = new.sl_avail, sl_color = new.sl_color, sl_len = new.sl_len, sl_unit = new.sl_unit
|
||||
ON UPDATE TO public.shoelace DO INSTEAD UPDATE shoelace_data SET sl_name = new.sl_name, sl_avail = new.sl_avail, sl_color = new.sl_color, sl_len = new.sl_len, sl_unit = new.sl_unit
|
||||
WHERE (shoelace_data.sl_name = old.sl_name);
|
||||
shoelace_data|log_shoelace|CREATE RULE log_shoelace AS
|
||||
ON UPDATE TO shoelace_data
|
||||
ON UPDATE TO public.shoelace_data
|
||||
WHERE (new.sl_avail <> old.sl_avail) DO INSERT INTO shoelace_log (sl_name, sl_avail, log_who, log_when)
|
||||
VALUES (new.sl_name, new.sl_avail, 'Al Bundy'::name, 'Thu Jan 01 00:00:00 1970'::timestamp without time zone);
|
||||
shoelace_ok|shoelace_ok_ins|CREATE RULE shoelace_ok_ins AS
|
||||
ON INSERT TO shoelace_ok DO INSTEAD UPDATE shoelace SET sl_avail = (shoelace.sl_avail + new.ok_quant)
|
||||
ON INSERT TO public.shoelace_ok DO INSTEAD UPDATE shoelace SET sl_avail = (shoelace.sl_avail + new.ok_quant)
|
||||
WHERE (shoelace.sl_name = new.ok_name);
|
||||
-- restore normal output mode
|
||||
\a\t
|
||||
@ -2873,7 +2873,7 @@ SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename;
|
||||
definition
|
||||
---------------------------------------------------------------------------------------------
|
||||
CREATE RULE hat_nosert AS +
|
||||
ON INSERT TO hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
|
||||
ON INSERT TO public.hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
|
||||
VALUES (new.hat_name, new.hat_color) ON CONFLICT(hat_name COLLATE "C" bpchar_pattern_ops)+
|
||||
WHERE (hat_color = 'green'::bpchar) DO NOTHING +
|
||||
RETURNING hat_data.hat_name, +
|
||||
@ -2898,7 +2898,7 @@ SELECT tablename, rulename, definition FROM pg_rules
|
||||
tablename | rulename | definition
|
||||
-----------+------------+---------------------------------------------------------------------------------------------
|
||||
hats | hat_nosert | CREATE RULE hat_nosert AS +
|
||||
| | ON INSERT TO hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
|
||||
| | ON INSERT TO public.hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
|
||||
| | VALUES (new.hat_name, new.hat_color) ON CONFLICT(hat_name COLLATE "C" bpchar_pattern_ops)+
|
||||
| | WHERE (hat_color = 'green'::bpchar) DO NOTHING +
|
||||
| | RETURNING hat_data.hat_name, +
|
||||
@ -2916,12 +2916,12 @@ CREATE RULE hat_nosert_all AS ON INSERT TO hats
|
||||
DO NOTHING
|
||||
RETURNING *;
|
||||
SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename;
|
||||
definition
|
||||
------------------------------------------------------------------------------
|
||||
CREATE RULE hat_nosert_all AS +
|
||||
ON INSERT TO hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color)+
|
||||
VALUES (new.hat_name, new.hat_color) ON CONFLICT DO NOTHING +
|
||||
RETURNING hat_data.hat_name, +
|
||||
definition
|
||||
-------------------------------------------------------------------------------------
|
||||
CREATE RULE hat_nosert_all AS +
|
||||
ON INSERT TO public.hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color)+
|
||||
VALUES (new.hat_name, new.hat_color) ON CONFLICT DO NOTHING +
|
||||
RETURNING hat_data.hat_name, +
|
||||
hat_data.hat_color;
|
||||
(1 row)
|
||||
|
||||
@ -2948,7 +2948,7 @@ SELECT definition FROM pg_rules WHERE tablename = 'hats' ORDER BY rulename;
|
||||
definition
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------
|
||||
CREATE RULE hat_upsert AS +
|
||||
ON INSERT TO hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
|
||||
ON INSERT TO public.hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
|
||||
VALUES (new.hat_name, new.hat_color) ON CONFLICT(hat_name) DO UPDATE SET hat_name = hat_data.hat_name, hat_color = excluded.hat_color+
|
||||
WHERE ((excluded.hat_color <> 'forbidden'::bpchar) AND (hat_data.* <> excluded.*)) +
|
||||
RETURNING hat_data.hat_name, +
|
||||
@ -2996,7 +2996,7 @@ SELECT tablename, rulename, definition FROM pg_rules
|
||||
tablename | rulename | definition
|
||||
-----------+------------+-----------------------------------------------------------------------------------------------------------------------------------------
|
||||
hats | hat_upsert | CREATE RULE hat_upsert AS +
|
||||
| | ON INSERT TO hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
|
||||
| | ON INSERT TO public.hats DO INSTEAD INSERT INTO hat_data (hat_name, hat_color) +
|
||||
| | VALUES (new.hat_name, new.hat_color) ON CONFLICT(hat_name) DO UPDATE SET hat_name = hat_data.hat_name, hat_color = excluded.hat_color+
|
||||
| | WHERE ((excluded.hat_color <> 'forbidden'::bpchar) AND (hat_data.* <> excluded.*)) +
|
||||
| | RETURNING hat_data.hat_name, +
|
||||
|
@ -391,9 +391,9 @@ SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE tgrelid = 'main_table'
|
||||
(1 row)
|
||||
|
||||
SELECT pg_get_triggerdef(oid, false) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a';
|
||||
pg_get_triggerdef
|
||||
----------------------------------------------------------------------------------------------------------------------------------------------
|
||||
CREATE TRIGGER modified_a BEFORE UPDATE OF a ON main_table FOR EACH ROW WHEN ((old.a <> new.a)) EXECUTE PROCEDURE trigger_func('modified_a')
|
||||
pg_get_triggerdef
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
CREATE TRIGGER modified_a BEFORE UPDATE OF a ON public.main_table FOR EACH ROW WHEN ((old.a <> new.a)) EXECUTE PROCEDURE trigger_func('modified_a')
|
||||
(1 row)
|
||||
|
||||
SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_any';
|
||||
@ -421,9 +421,9 @@ FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('before_upd_a_stmt');
|
||||
CREATE TRIGGER after_upd_b_stmt_trig AFTER UPDATE OF b ON main_table
|
||||
FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('after_upd_b_stmt');
|
||||
SELECT pg_get_triggerdef(oid) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'after_upd_a_b_row_trig';
|
||||
pg_get_triggerdef
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------
|
||||
CREATE TRIGGER after_upd_a_b_row_trig AFTER UPDATE OF a, b ON main_table FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_a_b_row')
|
||||
pg_get_triggerdef
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
CREATE TRIGGER after_upd_a_b_row_trig AFTER UPDATE OF a, b ON public.main_table FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_a_b_row')
|
||||
(1 row)
|
||||
|
||||
UPDATE main_table SET a = 50;
|
||||
|
Loading…
x
Reference in New Issue
Block a user