pg_upgrade fails with non-standard ACL
pg_upgrade from 9.6 fails if old cluster had non-standard ACL
on pg_catalog functions that have changed between versions,
for example pg_stop_backup(boolean).
Error:
pg_restore: creating ACL "pg_catalog.FUNCTION "pg_stop_backup"()"
pg_restore: creating ACL "pg_catalog.FUNCTION
"pg_stop_backup"("exclusive" boolean, OUT "lsn" "pg_lsn", OUT
"labelfile" "text", OUT "spcmapfile" "text")"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 2169; 0 0 ACL FUNCTION
"pg_stop_backup"("exclusive" boolean, OUT "lsn" "pg_lsn", OUT
"labelfile" "text", OUT "spcmapfile" "text") anastasia
pg_restore: [archiver (db)] could not execute query: ERROR: function
pg_catalog.pg_stop_backup(boolean) does not exist
Command was: GRANT ALL ON FUNCTION
"pg_catalog"."pg_stop_backup"("exclusive" boolean, OUT "lsn" "pg_lsn",
OUT "labelfile" "text", OUT "spcmapfile" "text") TO "backup";
Steps to reproduce:
1) create a database with pg9.6
2) create a user and change grants on pg_stop_backup(boolean):
CREATE ROLE backup WITH LOGIN;
GRANT USAGE ON SCHEMA pg_catalog TO backup;
GRANT EXECUTE ON FUNCTION pg_stop_backup() TO backup;
GRANT EXECUTE ON FUNCTION pg_stop_backup(boolean) TO backup;
3) perform pg_upgrade to v10 (or any version above)
The problem exists since we added to pg_dump support of ACL changes of
pg_catalog functions in commit 23f34fa4b.
I think this is a bug since it unpredictably affects user experience, so
I propose to backpatch the fix.
Script to reproduce the problem and the patch to fix it (credit to
Arthur Zakirov) are attached.
Current patch contains a flag for pg_dump --change-old-names to enforce
correct behavior.
I wonder, if we can make it default behavior for pg_upgrade?
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_dump_ACL_fix_v0.patchtext/x-patch; name=pg_dump_ACL_fix_v0.patchDownload
diff --git a/src/bin/pg_dump/pg_backup.h b/src/bin/pg_dump/pg_backup.h
index bebec79..3c17a67 100644
--- a/src/bin/pg_dump/pg_backup.h
+++ b/src/bin/pg_dump/pg_backup.h
@@ -146,6 +146,7 @@ typedef struct _dumpOptions
/* flags for various command-line long options */
int disable_dollar_quoting;
int dump_inserts;
+ int change_old_names;
int column_inserts;
int if_exists;
int no_comments;
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 384b32b..4345d4e 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -245,7 +245,7 @@ static void makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo, bool oids);
static void buildMatViewRefreshDependencies(Archive *fout);
static void getTableDataFKConstraints(void);
static char *format_function_arguments(FuncInfo *finfo, char *funcargs,
- bool is_agg);
+ bool is_agg, bool change_old_names);
static char *format_function_arguments_old(Archive *fout,
FuncInfo *finfo, int nallargs,
char **allargtypes,
@@ -360,6 +360,7 @@ main(int argc, char **argv)
*/
{"attribute-inserts", no_argument, &dopt.column_inserts, 1},
{"binary-upgrade", no_argument, &dopt.binary_upgrade, 1},
+ {"change-old-names", no_argument, &dopt.change_old_names, 1},
{"column-inserts", no_argument, &dopt.column_inserts, 1},
{"disable-dollar-quoting", no_argument, &dopt.disable_dollar_quoting, 1},
{"disable-triggers", no_argument, &dopt.disable_triggers, 1},
@@ -11538,6 +11539,65 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
destroyPQExpBuffer(delqry);
}
+typedef struct FunctionMapping
+{
+ const char *old_name;
+ const char *old_args;
+ const char *new_name;
+ const char *new_args;
+} FunctionMapping;
+
+/*
+ * This array is used to map old names and arguments with new values.
+ */
+static FunctionMapping func_mappings[] =
+{
+ /* Renames */
+ { "pg_current_xlog_flush_location", NULL, "pg_current_wal_flush_lsn", NULL},
+ { "pg_current_xlog_insert_location", NULL, "pg_current_wal_insert_lsn", NULL},
+ { "pg_current_xlog_location", NULL, "pg_current_wal_lsn", NULL},
+ { "pg_is_xlog_replay_paused", NULL, "pg_is_wal_replay_paused", NULL},
+ { "pg_last_xlog_receive_location", NULL, "pg_last_wal_receive_lsn", NULL},
+ { "pg_last_xlog_replay_location", NULL, "pg_last_wal_replay_lsn", NULL},
+ { "pg_switch_xlog", NULL, "pg_switch_wal", NULL},
+ { "pg_xlog_location_diff", NULL, "pg_wal_lsn_diff", NULL},
+ { "pg_xlog_replay_pause", NULL, "pg_wal_replay_pause", NULL},
+ { "pg_xlog_replay_resume", NULL, "pg_wal_replay_resume", NULL},
+ { "pg_xlogfile_name", NULL, "pg_walfile_name", NULL},
+ { "pg_xlogfile_name_offset", NULL, "pg_walfile_name_offset", NULL},
+
+ /* Argument changes */
+
+ {
+ "pg_create_logical_replication_slot",
+ "\"slot_name\" \"name\", \"plugin\" \"name\", OUT \"slot_name\" \"text\", OUT \"xlog_position\" \"pg_lsn\"",
+ "pg_create_logical_replication_slot",
+ "\"slot_name\" \"name\", \"plugin\" \"name\", \"temporary\" boolean, OUT \"slot_name\" \"text\", OUT \"lsn\" \"pg_lsn\""
+ },
+ {
+ "pg_create_physical_replication_slot",
+ "\"slot_name\" \"name\", \"immediately_reserve\" boolean DEFAULT false, OUT \"slot_name\" \"name\", OUT \"xlog_position\" \"pg_lsn\"",
+ "pg_create_physical_replication_slot",
+ "\"slot_name\" \"name\", \"immediately_reserve\" boolean DEFAULT false, \"temporary\" boolean DEFAULT false, OUT \"slot_name\" \"name\", OUT \"lsn\" \"pg_lsn\"",
+ },
+ /* pg_create_physical_replication_slot without defaults */
+ {
+ "pg_create_physical_replication_slot",
+ "\"slot_name\" \"name\", \"immediately_reserve\" boolean, OUT \"slot_name\" \"name\", OUT \"xlog_position\" \"pg_lsn\"",
+ "pg_create_physical_replication_slot",
+ "\"slot_name\" \"name\", \"immediately_reserve\" boolean, \"temporary\" boolean, OUT \"slot_name\" \"name\", OUT \"lsn\" \"pg_lsn\"",
+ },
+ {
+ "pg_stop_backup",
+ "\"exclusive\" boolean, OUT \"lsn\" \"pg_lsn\", OUT \"labelfile\" \"text\", OUT \"spcmapfile\" \"text\"",
+ "pg_stop_backup",
+ "\"exclusive\" boolean, \"wait_for_archive\" boolean, OUT \"lsn\" \"pg_lsn\", OUT \"labelfile\" \"text\", OUT \"spcmapfile\" \"text\""
+ },
+
+ /* end of mappings */
+ { NULL }
+};
+
/*
* format_function_arguments: generate function name and argument list
*
@@ -11546,16 +11606,52 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
* does not special-case zero-argument aggregates.
*/
static char *
-format_function_arguments(FuncInfo *finfo, char *funcargs, bool is_agg)
+format_function_arguments(FuncInfo *finfo, char *funcargs, bool is_agg,
+ bool change_old_names)
{
PQExpBufferData fn;
+ const char *name = finfo->dobj.name;
+ const char *args = funcargs;
+ int i;
+
+ /*
+ * Map old names and arguments with new names. If --change-old-names is set
+ * then old names and arguments are replaced and new values will be wrote in
+ * pg_dump output.
+ *
+ * Currently mapping works only if --quote-all-identifiers is set. Otherwise
+ * it requires to handle mappings without quotes. But it is enough for
+ * pg_upgrade wich runs pg_dump with --quote-all-identifiers
+ */
+ if (change_old_names && quote_all_identifiers)
+ {
+ for (i = 0; func_mappings[i].old_name; i++)
+ {
+ FunctionMapping *map = &func_mappings[i];
+
+ /* If arguments don't matter */
+ if (strcmp(map->old_name, name) == 0 && map->old_args == NULL)
+ {
+ name = map->new_name;
+ break;
+ }
+ /* Rename with arguments */
+ else if (strcmp(map->old_name, name) == 0 &&
+ strcmp(map->old_args, args) == 0)
+ {
+ name = map->new_name;
+ args = map->new_args;
+ break;
+ }
+ }
+ }
initPQExpBuffer(&fn);
- appendPQExpBufferStr(&fn, fmtId(finfo->dobj.name));
+ appendPQExpBufferStr(&fn, fmtId(name));
if (is_agg && finfo->nargs == 0)
appendPQExpBufferStr(&fn, "(*)");
else
- appendPQExpBuffer(&fn, "(%s)", funcargs);
+ appendPQExpBuffer(&fn, "(%s)", args);
return fn.data;
}
@@ -12002,9 +12098,18 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
if (funcargs)
{
+ bool change_old_names;
+
+ /* pre-10, map old names and arguments with new names if necessary */
+ change_old_names = fout->remoteVersion < 100000 &&
+ dopt->change_old_names == 1 &&
+ strcmp(finfo->dobj.namespace->dobj.name, "pg_catalog") == 0;
+
/* 8.4 or later; we rely on server-side code for most of the work */
- funcfullsig = format_function_arguments(finfo, funcargs, false);
- funcsig = format_function_arguments(finfo, funciargs, false);
+ funcfullsig = format_function_arguments(finfo, funcargs, false,
+ change_old_names);
+ funcsig = format_function_arguments(finfo, funciargs, false,
+ change_old_names);
}
else
/* pre-8.4, do it ourselves */
@@ -14009,11 +14114,19 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
/* 8.4 or later; we rely on server-side code for most of the work */
char *funcargs;
char *funciargs;
+ bool change_old_names;
+
+ /* pre-10, map old names and arguments with new names if necessary */
+ change_old_names = fout->remoteVersion < 100000 &&
+ dopt->change_old_names == 1 &&
+ strcmp(agginfo->aggfn.dobj.namespace->dobj.name, "pg_catalog") == 0;
funcargs = PQgetvalue(res, 0, PQfnumber(res, "funcargs"));
funciargs = PQgetvalue(res, 0, PQfnumber(res, "funciargs"));
- aggfullsig = format_function_arguments(&agginfo->aggfn, funcargs, true);
- aggsig = format_function_arguments(&agginfo->aggfn, funciargs, true);
+ aggfullsig = format_function_arguments(&agginfo->aggfn, funcargs, true,
+ change_old_names);
+ aggsig = format_function_arguments(&agginfo->aggfn, funciargs, true,
+ change_old_names);
}
else
/* pre-8.4, do it ourselves */
diff --git a/src/bin/pg_upgrade/dump.c b/src/bin/pg_upgrade/dump.c
index def22c6..697a7b5 100644
--- a/src/bin/pg_upgrade/dump.c
+++ b/src/bin/pg_upgrade/dump.c
@@ -54,6 +54,7 @@ generate_old_dump(void)
parallel_exec_prog(log_file_name, NULL,
"\"%s/pg_dump\" %s --schema-only --quote-all-identifiers "
+ "--change-old-names "
"--binary-upgrade --format=custom %s --file=\"%s\" %s",
new_cluster.bindir, cluster_conn_opts(&old_cluster),
log_opts.verbose ? "--verbose" : "",
On Thu, Jul 18, 2019 at 06:53:12PM +0300, Anastasia Lubennikova wrote:
pg_upgrade from 9.6 fails if old cluster had non-standard ACL
on pg_catalog functions that have changed between versions,
for example pg_stop_backup(boolean).Error:
pg_restore: creating ACL "pg_catalog.FUNCTION "pg_stop_backup"()"
pg_restore: creating ACL "pg_catalog.FUNCTION "pg_stop_backup"("exclusive"
boolean, OUT "lsn" "pg_lsn", OUT "labelfile" "text", OUT "spcmapfile"
"text")"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 2169; 0 0 ACL FUNCTION
"pg_stop_backup"("exclusive" boolean, OUT "lsn" "pg_lsn", OUT "labelfile"
"text", OUT "spcmapfile" "text") anastasia
pg_restore: [archiver (db)] could not execute query: ERROR: function
pg_catalog.pg_stop_backup(boolean) does not exist
��� Command was: GRANT ALL ON FUNCTION
"pg_catalog"."pg_stop_backup"("exclusive" boolean, OUT "lsn" "pg_lsn", OUT
"labelfile" "text", OUT "spcmapfile" "text") TO "backup";Steps to reproduce:
1) create a database with pg9.6
2) create a user and change grants on pg_stop_backup(boolean):
CREATE ROLE backup WITH LOGIN;
GRANT USAGE ON SCHEMA pg_catalog TO backup;
GRANT EXECUTE ON FUNCTION pg_stop_backup() TO backup;
GRANT EXECUTE ON FUNCTION pg_stop_backup(boolean) TO backup;
3) perform pg_upgrade to v10 (or any version above)The problem exists since we added to pg_dump support of ACL changes of
pg_catalog functions in commit 23f34fa4b.I think this is a bug since it unpredictably affects user experience, so I
propose to backpatch the fix.
Script to reproduce the problem and the patch to fix it (credit to Arthur
Zakirov) are attached.
Uh, wouldn't this affect any default-installed function where the
permission are modified? Is fixing only a few functions really helpful?
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Bruce Momjian <bruce@momjian.us> writes:
On Thu, Jul 18, 2019 at 06:53:12PM +0300, Anastasia Lubennikova wrote:
pg_upgrade from 9.6 fails if old cluster had non-standard ACL
on pg_catalog functions that have changed between versions,
for example pg_stop_backup(boolean).
Uh, wouldn't this affect any default-installed function where the
permission are modified? Is fixing only a few functions really helpful?
No, it's just functions whose signatures have changed enough that
a GRANT won't find them. I think the idea is that the set of
potentially-affected functions is determinate. I have to say that
the proposed patch seems like a complete kluge, though. For one
thing we'd have to maintain the list of affected functions in each
future release, and I have no faith in our remembering to do that.
It's also fair to question whether pg_upgrade should even try to
cope with such cases. If the function has changed signature,
it might well be that it's also changed behavior enough so that
any previously-made grants need reconsideration. (Maybe we should
just suppress the old grant rather than transferring it.)
Still, this does seem like a gap in the pg_init_privs mechanism.
I wonder if Stephen has any thoughts about what ought to happen.
regards, tom lane
Greetings,
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
Bruce Momjian <bruce@momjian.us> writes:
On Thu, Jul 18, 2019 at 06:53:12PM +0300, Anastasia Lubennikova wrote:
pg_upgrade from 9.6 fails if old cluster had non-standard ACL
on pg_catalog functions that have changed between versions,
for example pg_stop_backup(boolean).Uh, wouldn't this affect any default-installed function where the
permission are modified? Is fixing only a few functions really helpful?No, it's just functions whose signatures have changed enough that
a GRANT won't find them. I think the idea is that the set of
potentially-affected functions is determinate. I have to say that
the proposed patch seems like a complete kluge, though. For one
thing we'd have to maintain the list of affected functions in each
future release, and I have no faith in our remembering to do that.
Well, we aren't likely to do that ourselves, no, but perhaps we could
manage it with some prodding by having the buildfarm check for such
cases, not unlike how library maintainers check the ABI between versions
of the library they manage. Extension authors also deal with these
kinds of changes routinely when writing the upgrade scripts to go
between versions of their extension. I'm not convinced that this is a
great approach to go down either, to be clear. When going across major
versions, making people update their systems/code and re-test is
typically entirely reasonable to me.
It's also fair to question whether pg_upgrade should even try to
cope with such cases. If the function has changed signature,
it might well be that it's also changed behavior enough so that
any previously-made grants need reconsideration. (Maybe we should
just suppress the old grant rather than transferring it.)
Suppressing the GRANT strikes me as pretty reasonable as an approach but
wouldn't that require us to similairly track what's changed between
major versions..? Unless we arrange to ignore the GRANT failing, but
that seems like it would involve a fair bit of hacking around in pg_dump
to have some option to ignore certain GRANTs failing. Did you have some
other idea about how to suppress the old GRANT?
A way to make things work for users while suppressing the GRANTS would
be to add a default role for things like file-level-backup, which would
be allowed to execute file-level-backup related functions, presumably
even if we make changes to exactly what those function signatures are,
and then encourage users to GRANT that role to the role that's allowed
to log in and run the file-level backup. Obviously we wouldn't be doing
that in the back-branches, but we could moving forward.
Still, this does seem like a gap in the pg_init_privs mechanism.
I wonder if Stephen has any thoughts about what ought to happen.
So, in an interesting sort of way, we have a way to deal with this
problem when it comes to *extensions* and I suppose that's why we
haven't seen it there- namely the upgrade script, which can decide if it
wants to drop an object and recreate it, or if it wants to do a
create-or-replace, which would preserve the privileges (though the API
has to stay the same, so that isn't exactly the same) and avoid dropping
dependant objects.
Unfortunately, we don't have any good way today to add an optional
argument to a function while preserving the privileges on it, which
would make a case like this one (and others where you'd prefer to not
drop/recreate the function due to dependencies) work, for extensions.
Suppressing the GRANT also seems reasonable for the case of objects
which have been renamed- clearly whatever is using those functions is
going to have to be modified to deal with the new name of the function,
requiring that the GRANT be re-issued doesn't seem like it's that much
more to ask of users. On the other hand, properly written tools that
check the version of PG and use the right function names could possibly
"just work" following a major version upgrade, if the privilege was
brought across to the new major version correctly.
We also don't want to mistakenly GRANT users more access then they
should have though- if pg_stop_backup() one day grows an
optional argument to run some server-side script, I don't think we'd
want to necessairly just give access to that ability to roles who,
today, can execute the current pg_stop_backup() function. Of course, if
we added such a capability, hopefully we would do so in a way that less
privileged roles could continue to use the existing capability without
having access to run such a server-side script.
I also don't think that the current patch is actually sufficient to deal
with all the changes we've made between the versions- what about column
names on catalog tables/views that were removed, or changed/renamed..?
In an ideal world, it seems like we'd make a judgement call and arrange
to pull the privileges across when we can do so without granting the
user privileges beyond those that were intended, and otherwise we'd
suppress the GRANT to avoid getting an error. I'm not sure what a good
way is to go about either figuring out a way to pull the privileges
across, or to suppress the GRANTs when we need to (or always), would be
though. Neither seems easy to solve in a clean way.
Certainly open to suggestions.
Thanks,
Stephen
29.07.2019 18:37, Stephen Frost wrote:
Greetings,
* Tom Lane (tgl@sss.pgh.pa.us) wrote:
Bruce Momjian <bruce@momjian.us> writes:
On Thu, Jul 18, 2019 at 06:53:12PM +0300, Anastasia Lubennikova wrote:
pg_upgrade from 9.6 fails if old cluster had non-standard ACL
on pg_catalog functions that have changed between versions,
for example pg_stop_backup(boolean).Uh, wouldn't this affect any default-installed function where the
permission are modified? Is fixing only a few functions really helpful?No, it's just functions whose signatures have changed enough that
a GRANT won't find them. I think the idea is that the set of
potentially-affected functions is determinate. I have to say that
the proposed patch seems like a complete kluge, though. For one
thing we'd have to maintain the list of affected functions in each
future release, and I have no faith in our remembering to do that.Well, we aren't likely to do that ourselves, no, but perhaps we could
manage it with some prodding by having the buildfarm check for such
cases, not unlike how library maintainers check the ABI between versions
of the library they manage. Extension authors also deal with these
kinds of changes routinely when writing the upgrade scripts to go
between versions of their extension. I'm not convinced that this is a
great approach to go down either, to be clear. When going across major
versions, making people update their systems/code and re-test is
typically entirely reasonable to me.
Whatever we choose to do, we need to keep a list of changed functions. I
don't
think that it will add too much extra work to maintaining other catalog
changes
such as adding or renaming columns.
What's more, we must mention changed functions in migration release
notes. I've
checked documentation [1]https://www.postgresql.org/docs/10/release-10.html and found out, that function API changes are not
described properly.
I think it is an important omission, so I attached the patch for
documentation.
Not quite sure, how many users have already migrated to version 10, still, I
believe it will help many others.
Suppressing the GRANT also seems reasonable for the case of objects
which have been renamed- clearly whatever is using those functions is
going to have to be modified to deal with the new name of the function,
requiring that the GRANT be re-issued doesn't seem like it's that much
more to ask of users. On the other hand, properly written tools that
check the version of PG and use the right function names could possibly
"just work" following a major version upgrade, if the privilege was
brought across to the new major version correctly.
That's exactly the case.
We also don't want to mistakenly GRANT users more access then they
should have though- if pg_stop_backup() one day grows an
optional argument to run some server-side script, I don't think we'd
want to necessairly just give access to that ability to roles who,
today, can execute the current pg_stop_backup() function. Of course, if
we added such a capability, hopefully we would do so in a way that less
privileged roles could continue to use the existing capability without
having access to run such a server-side script.I also don't think that the current patch is actually sufficient to deal
with all the changes we've made between the versions- what about column
names on catalog tables/views that were removed, or changed/renamed..?
I can't get the problem you describe here. As far as I understand, various
changes of catalog tables and views are already handled correctly in
pg_upgrade.
In an ideal world, it seems like we'd make a judgement call and arrange
to pull the privileges across when we can do so without granting the
user privileges beyond those that were intended, and otherwise we'd
suppress the GRANT to avoid getting an error. I'm not sure what a good
way is to go about either figuring out a way to pull the privileges
across, or to suppress the GRANTs when we need to (or always), would be
though. Neither seems easy to solve in a clean way.Certainly open to suggestions.
Based on our initial bug report, I would vote against suppressing the
GRANTS,
because it leads to an unexpected failure in case a user has a special
role for
use in a third-party utility such as a backup tool, which already took
care of
internal API changes.
Still I agree with your arguments about possibility of providing more grants
than expected. Ideally, we do not change behaviour of existing functions
that
much, but in real-world it may happen.
Maybe, as a compromise, we can reset grants to default for all changed
functions
and also generate a script that will allow a user to preserve privileges
of the
old cluster by analogy with analyze_new_cluster script.
What do you think?
[1]: https://www.postgresql.org/docs/10/release-10.html
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
doc-function-API-change_v10.patchtext/x-patch; name=doc-function-API-change_v10.patchDownload
diff --git a/doc/src/sgml/release-10.sgml b/doc/src/sgml/release-10.sgml
index 7b2130e3c1..1b685b44da 100644
--- a/doc/src/sgml/release-10.sgml
+++ b/doc/src/sgml/release-10.sgml
@@ -9230,6 +9230,32 @@ Branch: REL_10_STABLE [5159626af] 2017-11-03 14:14:16 -0400
</para>
</listitem>
+ <listitem>
+<!--
+2017-03-22 [017e4f258] Expose waitforarchive option through pg_stop_backup()
+2017-08-05 [52f8a59dd] Make pg_stop_backup's wait_for_archive flag work on stan
+-->
+ <para>
+ Add an optional <literal>wait_for_archive</literal> argument to the <link
+ linkend="functions-admin"><function>pg_stop_backup()</function></link>
+ function to allow waiting for all <acronym>WAL</acronym> to be archived (David Steele)
+ </para>
+ </listitem>
+
+ <listitem>
+<!--
+2016-12-12 [a924c327e] Add support for temporary replication slots
+-->
+ <para>
+ Add an optional <literal>temporary</literal> argument to
+ <literal>pg_create_logical_replication_slot()</literal>
+ and <literal>pg_create_physical_replication_slot()</literal> functions
+ to allow creation of <link
+ linkend="functions-replication-table">temporary replication slots</link>
+ (Petr Jelinek)
+ </para>
+ </listitem>
+
</itemizedlist>
</sect2>
On Tue, Aug 13, 2019 at 07:04:42PM +0300, Anastasia Lubennikova wrote:
In an ideal world, it seems like we'd make a judgement call and arrange
to pull the privileges across when we can do so without granting the
user privileges beyond those that were intended, and otherwise we'd
suppress the GRANT to avoid getting an error. I'm not sure what a good
way is to go about either figuring out a way to pull the privileges
across, or to suppress the GRANTs when we need to (or always), would be
though. Neither seems easy to solve in a clean way.Certainly open to suggestions.
Based on our initial bug report, I would vote against suppressing the
GRANTS,
because it leads to an unexpected failure in case a user has a special role
for
use in a third-party utility such as a backup tool, which already took care
of
internal API changes.Still I agree with your arguments about possibility of providing more grants
than expected. Ideally, we do not change behaviour of existing functions
that
much, but in real-world it may happen.Maybe, as a compromise, we can reset grants to default for all changed
functions
and also generate a script that will allow a user to preserve privileges of
the
old cluster by analogy with analyze_new_cluster script.
What do you think?
I agree pg_upgrade should work without user correction as much as
possible. However, as you can see, it can fail when user objects
reference system table objects that have changed between major releases.
As much as it would be nice if the release notes covered all that, and
we updated pg_upgrade to somehow handle them, it just isn't realistic.
As we can see here, the problems often take years to show up, and even
then there were probably many other people who had the problem who never
reported it to us.
I think a realistic approach is to come up with a list of all the user
behaviors that can cause pg_upgrade to break (by reviewing previous
pg_upgrade bug reports), and then add code to pg_upgrade to detect them
and either fix them or report them in --check mode.
In summary, I am saying that the odds that patch authors, committers,
release note writers, and pg_upgrade maintainers are going to form a
consistent work flow that catches all these changes is unrealistic ---
our best bet is to create something in the pg_upgrade code to detects
this. pg_upgrade already connects to the old and new cluster, so
technically it can perform system table modification checks itself.
The only positive is that when pg_upgrade does fail, at least we have a
system that clearly points to the cause, but unfortunately usually at
run-time, not at --check time.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Greetings,
* Bruce Momjian (bruce@momjian.us) wrote:
On Tue, Aug 13, 2019 at 07:04:42PM +0300, Anastasia Lubennikova wrote:
Maybe, as a compromise, we can reset grants to default for all changed
functions
and also generate a script that will allow a user to preserve privileges of
the
old cluster by analogy with analyze_new_cluster script.
What do you think?I agree pg_upgrade should work without user correction as much as
possible. However, as you can see, it can fail when user objects
reference system table objects that have changed between major releases.
Right.
As much as it would be nice if the release notes covered all that, and
we updated pg_upgrade to somehow handle them, it just isn't realistic.
As we can see here, the problems often take years to show up, and even
then there were probably many other people who had the problem who never
reported it to us.
Yeah, the possible changes when you think about column-level privileges
as well really gets to be quite large..
This is why my thinking is that we should come up with additional
default roles, which aren't tied to specific catalog structures but
instead are for a more general set of capabilities which we manage and
users can either decide to use, or not. If they decide to work with the
individual functions then they have to manage the upgrade process if and
when we make changes to those functions.
I think a realistic approach is to come up with a list of all the user
behaviors that can cause pg_upgrade to break (by reviewing previous
pg_upgrade bug reports), and then add code to pg_upgrade to detect them
and either fix them or report them in --check mode.
In this case, we could, at least conceptually, perform a comparison
between the different major versions and then check for any non-default
privileges for any of the objects changed and then report on those in
--check mode with a recommendation to revert to the default privileges
in the old cluster before running pg_upgrade, and then apply whatever
privileges are desired in the new cluster after the upgrade completes.
In summary, I am saying that the odds that patch authors, committers,
release note writers, and pg_upgrade maintainers are going to form a
consistent work flow that catches all these changes is unrealistic ---
our best bet is to create something in the pg_upgrade code to detects
this. pg_upgrade already connects to the old and new cluster, so
technically it can perform system table modification checks itself.
It'd be pretty neat if pg_upgrade could connect to the old and new
clusters concurrently and then perform a generic catalog comparison
between them and identify all objects which have been changed and
determine if there's any non-default ACLs or dependencies on the catalog
objects which are different between the clusters. That seems like an
awful lot of work though, and I'm not sure there's really any need,
given that we don't change the catalog for a given major version- we
could just generate the list using some queries whenever we release a
new major version and update pg_upgrade with it.
The only positive is that when pg_upgrade does fail, at least we have a
system that clearly points to the cause, but unfortunately usually at
run-time, not at --check time.
Getting it to be at check time would certainly be a great improvement.
Solving this in pg_upgrade does seem like it's probably the better
approach rather than trying to do it in pg_dump. Unfortunately, that
likely means that all we can do is have pg_upgrade point out to the user
when something will fail, with recommendations on how to address it, but
that's also something users are likely used to and willing to accept,
and puts the onus on them to consider their ACL decisions when we're
making catalog changes, and it keeps these issues out of pg_dump.
Thanks,
Stephen
On Tue, Aug 13, 2019 at 08:28:12PM -0400, Stephen Frost wrote:
Getting it to be at check time would certainly be a great improvement.
Solving this in pg_upgrade does seem like it's probably the better
approach rather than trying to do it in pg_dump. Unfortunately, that
likely means that all we can do is have pg_upgrade point out to the user
when something will fail, with recommendations on how to address it, but
that's also something users are likely used to and willing to accept,
and puts the onus on them to consider their ACL decisions when we're
making catalog changes, and it keeps these issues out of pg_dump.
Yeah, I think we just need to bite the bullet and create some
infrastructure to help folks solve the problem.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
14.08.2019 3:28, Stephen Frost wrote:
* Bruce Momjian (bruce@momjian.us) wrote:
As much as it would be nice if the release notes covered all that, and
we updated pg_upgrade to somehow handle them, it just isn't realistic.
As we can see here, the problems often take years to show up, and even
then there were probably many other people who had the problem who never
reported it to us.Yeah, the possible changes when you think about column-level privileges
as well really gets to be quite large..This is why my thinking is that we should come up with additional
default roles, which aren't tied to specific catalog structures but
instead are for a more general set of capabilities which we manage and
users can either decide to use, or not. If they decide to work with the
individual functions then they have to manage the upgrade process if and
when we make changes to those functions.
Idea of having special roles looks good to me, though, I don't see
how to define what grants are needed for each role. Let's say, we
define role "backupuser" that obviously must have grants on
pg_start_backup()
and pg_stop_backup(). Should it also have access to pg_is_in_recovery()
or for example version()?
It'd be pretty neat if pg_upgrade could connect to the old and new
clusters concurrently and then perform a generic catalog comparison
between them and identify all objects which have been changed and
determine if there's any non-default ACLs or dependencies on the catalog
objects which are different between the clusters. That seems like an
awful lot of work though, and I'm not sure there's really any need,
given that we don't change the catalog for a given major version- we
could just generate the list using some queries whenever we release a
new major version and update pg_upgrade with it.The only positive is that when pg_upgrade does fail, at least we have a
system that clearly points to the cause, but unfortunately usually at
run-time, not at --check time.Getting it to be at check time would certainly be a great improvement.
Solving this in pg_upgrade does seem like it's probably the better
approach rather than trying to do it in pg_dump. Unfortunately, that
likely means that all we can do is have pg_upgrade point out to the user
when something will fail, with recommendations on how to address it, but
that's also something users are likely used to and willing to accept,
and puts the onus on them to consider their ACL decisions when we're
making catalog changes, and it keeps these issues out of pg_dump.
I wrote a prototype to check API and ACL compatibility (see attachment).
In the current implementation it fetches the list of system procedures
for both old and new clusters
and reports deleted functions or ACL changes during pg_upgrade check:
Performing Consistency Checks
-----------------------------
...
Checking for system functions API compatibility
dbname postgres : check procsig is equal pg_stop_backup(), procacl not
equal {anastasia=X/anastasia,backup=X/anastasia} vs {anastasia=X/anastasia}
dbname postgres : procedure pg_stop_backup(exclusive boolean, OUT lsn
pg_lsn, OUT labelfile text, OUT spcmapfile text) doesn't exist in
new_cluster
dbname postgres : procedure pg_switch_xlog() doesn't exist in new_cluster
dbname postgres : procedure pg_xlog_replay_pause() doesn't exist in
new_cluster
dbname postgres : procedure pg_xlog_replay_resume() doesn't exist in
new_cluster
...
I think it's a good first step in the right direction.
Now I have questions about implementation details:
1) How exactly should we report this incompatibility to a user?
I think it's fine to leave the warnings and also write some hint for the
user by analogy with other checks.
"Reset ACL on the problem functions to default in the old cluster to
continue"
Is it enough?
2) This approach can be extended to other catalog modifications, you
mentioned above.
I don't see what else can break pg_upgrade in the same way. However, I
don't mind
implementing more checks, while I work on this issue, if you can point
on them.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v1.patchtext/x-patch; name=pg_upgrade_ACL_check_v1.patchDownload
commit 36e23da269d635ebfbc9891d37e650f8c3bfa6de
Author: Anastasia <a.lubennikova@postgrespro.ru>
Date: Mon Aug 19 19:38:51 2019 +0300
attempt to check proc signatures and ACL in pg_upgrade
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index b4cf6da..c12340a 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -90,6 +90,7 @@ check_and_dump_old_cluster(bool live_check)
get_loadable_libraries();
+ get_catalog_procedures(&old_cluster);
/*
* Check for various failure cases
@@ -148,6 +149,8 @@ check_new_cluster(void)
check_databases_are_compatible();
check_loadable_libraries();
+ get_catalog_procedures(&new_cluster);
+ check_catalog_procedures(&old_cluster, &new_cluster);
if (user_opts.transfer_mode == TRANSFER_MODE_LINK)
check_hard_link();
diff --git a/src/bin/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c
index 03fd155..78c5e2c 100644
--- a/src/bin/pg_upgrade/function.c
+++ b/src/bin/pg_upgrade/function.c
@@ -275,3 +275,157 @@ check_loadable_libraries(void)
else
check_ok();
}
+
+/*
+ * qsort comparator for procedure signatures
+ */
+static int
+proc_compare_sig(const void *p1, const void *p2)
+{
+ ProcInfo *proc1 = (ProcInfo *) p1;
+ ProcInfo *proc2 = (ProcInfo *) p2;
+
+ return strcmp(proc1->procsig, proc2->procsig);
+}
+
+/*
+ * get_catalog_procedures()
+ *
+ * Fetch the signatures and ACL of cluster's system procedures.
+ *
+ * TODO We will later check that funciton's APIs are compatible
+ * and suppress dumping of removed functions where needed.
+ */
+void
+get_catalog_procedures(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ /*
+ * Fetch all procedure signatures and ACL.
+ * Each procedure may have different ACL in different database.
+ */
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ int num_procs;
+ int rowno;
+
+ /*
+ * Fetch procedure signatures and ACL of functions that have
+ * some non default ACL.
+ *
+ * TODO Is it necessary to handle aggregate functions?
+ * TODO Should we handle functions with default (null) ACL?
+ */
+ if (cluster->major_version >= 110000)
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(oid)::text"
+ " || ')' as funsig,"
+ " proacl from pg_proc where prokind='f'"
+ " and proacl is not null;");
+ }
+ else
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(oid)::text"
+ " || ')' as funsig,"
+ " proacl from pg_proc where proisagg = false"
+ " and proacl is not null;");
+ }
+
+ num_procs = PQntuples(res);
+ dbinfo->proc_arr.nprocs = num_procs;
+ dbinfo->proc_arr.procs = (ProcInfo *) pg_malloc(sizeof(ProcInfo) * num_procs);
+
+ for (rowno = 0; rowno < num_procs; rowno++)
+ {
+ ProcInfo *curr = &dbinfo->proc_arr.procs[rowno];
+ char *procsig = PQgetvalue(res, rowno, 0);
+ char *procacl = PQgetvalue(res, rowno, 1);
+
+ curr->procsig = pg_strdup(procsig);
+ curr->procacl = pg_strdup(procacl);
+ }
+
+ qsort((void *) dbinfo->proc_arr.procs, dbinfo->proc_arr.nprocs, sizeof(ProcInfo),
+ proc_compare_sig);
+
+ PQclear(res);
+ PQfinish(conn);
+ }
+}
+
+/*
+ * Check API changes in pg_proc between old_cluster and new_cluster.
+ * Report functions that only exist in old_cluster
+ *
+ * TODO save such functions in some list or file to show useful ereport
+ * and/or generate script to help user to revoke non-standard ACL from
+ * these functions.
+ *
+ * NOTE it's vital to call it after check_databases_are_compatible(),
+ * because we rely on correct database order
+ */
+void
+check_catalog_procedures(ClusterInfo *old_cluster, ClusterInfo *new_cluster)
+{
+ int dbnum;
+
+ prep_status("Checking for system functions API compatibility\n");
+
+ for (dbnum = 0; dbnum < old_cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *olddbinfo = &old_cluster->dbarr.dbs[dbnum];
+ DbInfo *newdbinfo = &new_cluster->dbarr.dbs[dbnum];
+ int i, j;
+
+ if (strcmp(olddbinfo->db_name, newdbinfo->db_name) != 0)
+ pg_log(PG_FATAL, "check_catalog_procedures failed \n");
+
+ i = j = 0;
+ while (i < olddbinfo->proc_arr.nprocs && j < newdbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+ ProcInfo *newcurr = &newdbinfo->proc_arr.procs[j];
+ int result = strcmp(oldcurr->procsig, newcurr->procsig);
+
+ if (result == 0)
+ {
+ /* If system function has non defaule ACL? */
+ if (strcmp(oldcurr->procacl, newcurr->procacl) != 0)
+ pg_log(PG_WARNING, "dbname %s : check procsig is equal %s, procacl not equal %s vs %s\n",
+ olddbinfo->db_name, oldcurr->procsig, oldcurr->procacl, newcurr->procacl);
+ i++;
+ j++;
+ }
+ else if (result > 0)
+ {
+// pg_log(PG_WARNING, "dbname %s : procedure %s only exist in new_cluster\n",
+// olddbinfo->db_name, newcurr->procsig );
+ j++;
+ }
+ else
+ {
+ pg_log(PG_WARNING, "dbname %s : procedure %s doesn't exist in new_cluster\n",
+ olddbinfo->db_name, oldcurr->procsig);
+ i++;
+ }
+ }
+
+ /* handle tail of old_cluster proc list */
+ while (i < olddbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+
+ pg_log(PG_WARNING, "dbname %s : procedure %s doesn't exist in new_cluster\n",
+ olddbinfo->db_name, oldcurr->procsig);
+ i++;
+ }
+ }
+}
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 7e5e971..5ed4f8e 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -155,6 +155,19 @@ typedef struct
int nrels;
} RelInfoArr;
+typedef struct
+{
+ char *procsig; /* procedure signature */
+ char *procacl; /* ACL */
+} ProcInfo;
+
+typedef struct
+{
+ ProcInfo *procs;
+ int nprocs;
+} ProcInfoArr;
+
+
/*
* The following structure represents a relation mapping.
*/
@@ -191,6 +204,7 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ ProcInfoArr proc_arr; /* array of system procedures */
} DbInfo;
typedef struct
@@ -382,6 +396,9 @@ void check_hard_link(void);
void get_loadable_libraries(void);
void check_loadable_libraries(void);
+void get_catalog_procedures(ClusterInfo *cluster);
+void check_catalog_procedures(ClusterInfo *old_cluster,
+ ClusterInfo *new_cluster);
/* info.c */
Greetings,
* Anastasia Lubennikova (a.lubennikova@postgrespro.ru) wrote:
14.08.2019 3:28, Stephen Frost wrote:
* Bruce Momjian (bruce@momjian.us) wrote:
As much as it would be nice if the release notes covered all that, and
we updated pg_upgrade to somehow handle them, it just isn't realistic.
As we can see here, the problems often take years to show up, and even
then there were probably many other people who had the problem who never
reported it to us.Yeah, the possible changes when you think about column-level privileges
as well really gets to be quite large..This is why my thinking is that we should come up with additional
default roles, which aren't tied to specific catalog structures but
instead are for a more general set of capabilities which we manage and
users can either decide to use, or not. If they decide to work with the
individual functions then they have to manage the upgrade process if and
when we make changes to those functions.Idea of having special roles looks good to me, though, I don't see
how to define what grants are needed for each role. Let's say, we
define role "backupuser" that obviously must have grants on
pg_start_backup()
and pg_stop_backup(). Should it also have access to pg_is_in_recovery()
or for example version()?
pg_is_in_recovery() and version() are already allowed to be executed by
public, and I don't see any particular reason to change that, so I don't
believe those would need to be explicitly GRANT'd to this new role.
I would think the specific set would be those listed under:
https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-BACKUP
which currently require superuser access.
This isn't a new idea, btw, there was a great deal of discussion three
years ago around all of this. Particularly relevant is this:
/messages/by-id/20160104175516.GC3685@tamriel.snowman.net
It'd be pretty neat if pg_upgrade could connect to the old and new
clusters concurrently and then perform a generic catalog comparison
between them and identify all objects which have been changed and
determine if there's any non-default ACLs or dependencies on the catalog
objects which are different between the clusters. That seems like an
awful lot of work though, and I'm not sure there's really any need,
given that we don't change the catalog for a given major version- we
could just generate the list using some queries whenever we release a
new major version and update pg_upgrade with it.The only positive is that when pg_upgrade does fail, at least we have a
system that clearly points to the cause, but unfortunately usually at
run-time, not at --check time.Getting it to be at check time would certainly be a great improvement.
Solving this in pg_upgrade does seem like it's probably the better
approach rather than trying to do it in pg_dump. Unfortunately, that
likely means that all we can do is have pg_upgrade point out to the user
when something will fail, with recommendations on how to address it, but
that's also something users are likely used to and willing to accept,
and puts the onus on them to consider their ACL decisions when we're
making catalog changes, and it keeps these issues out of pg_dump.I wrote a prototype to check API and ACL compatibility (see attachment).
In the current implementation it fetches the list of system procedures for
both old and new clusters
and reports deleted functions or ACL changes during pg_upgrade check:Performing Consistency Checks
-----------------------------
...
Checking for system functions API compatibility
dbname postgres : check procsig is equal pg_stop_backup(), procacl not equal
{anastasia=X/anastasia,backup=X/anastasia} vs {anastasia=X/anastasia}
dbname postgres : procedure pg_stop_backup(exclusive boolean, OUT lsn
pg_lsn, OUT labelfile text, OUT spcmapfile text) doesn't exist in
new_cluster
dbname postgres : procedure pg_switch_xlog() doesn't exist in new_cluster
dbname postgres : procedure pg_xlog_replay_pause() doesn't exist in
new_cluster
dbname postgres : procedure pg_xlog_replay_resume() doesn't exist in
new_cluster
...I think it's a good first step in the right direction.
Now I have questions about implementation details:1) How exactly should we report this incompatibility to a user?
I think it's fine to leave the warnings and also write some hint for the
user by analogy with other checks.
"Reset ACL on the problem functions to default in the old cluster to
continue"Is it enough?
Not really sure what else we could do there..? Did you have something
else in mind? We could possibly provide the specific commands to run,
that seems like about the only other thing we could possibly do.
2) This approach can be extended to other catalog modifications, you
mentioned above.
I don't see what else can break pg_upgrade in the same way. However, I don't
mind
implementing more checks, while I work on this issue, if you can point on
them.
I was thinking of, for example, column-level privileges on system
relations (tables or views) where that column was later removed, for
example. I do appreciate that such changes are relatively rare but they
do happen...
Will try to take a look at the actual patch later today.
Thanks,
Stephen
On Tue, Aug 20, 2019 at 04:38:18PM +0300, Anastasia Lubennikova wrote:
Solving this in pg_upgrade does seem like it's probably the better
approach rather than trying to do it in pg_dump. Unfortunately, that
likely means that all we can do is have pg_upgrade point out to the user
when something will fail, with recommendations on how to address it, but
that's also something users are likely used to and willing to accept,
and puts the onus on them to consider their ACL decisions when we're
making catalog changes, and it keeps these issues out of pg_dump.I wrote a prototype to check API and ACL compatibility (see attachment).
In the current implementation it fetches the list of system procedures for
both old and new clusters
and reports deleted functions or ACL changes during pg_upgrade check:Performing Consistency Checks
-----------------------------
...
Checking for system functions API compatibility
dbname postgres : check procsig is equal pg_stop_backup(), procacl not equal
{anastasia=X/anastasia,backup=X/anastasia} vs {anastasia=X/anastasia}
dbname postgres : procedure pg_stop_backup(exclusive boolean, OUT lsn
pg_lsn, OUT labelfile text, OUT spcmapfile text) doesn't exist in
new_cluster
dbname postgres : procedure pg_switch_xlog() doesn't exist in new_cluster
dbname postgres : procedure pg_xlog_replay_pause() doesn't exist in
new_cluster
dbname postgres : procedure pg_xlog_replay_resume() doesn't exist in
new_cluster
...I think it's a good first step in the right direction.
Now I have questions about implementation details:1) How exactly should we report this incompatibility to a user?
I think it's fine to leave the warnings and also write some hint for the
user by analogy with other checks.
"Reset ACL on the problem functions to default in the old cluster to
continue"
Yes, I think it is good to at least throw an error during --check so
they don't have to find out during a live upgrade. Odds are it will
require manual repair.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Stephen,
On 2019-Aug-20, Stephen Frost wrote:
Will try to take a look at the actual patch later today.
Any word on that review?
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On 2019-Aug-21, Bruce Momjian wrote:
1) How exactly should we report this incompatibility to a user?
I think it's fine to leave the warnings and also write some hint for the
user by analogy with other checks.
"Reset ACL on the problem functions to default in the old cluster to
continue"Yes, I think it is good to at least throw an error during --check so
they don't have to find out during a live upgrade. Odds are it will
require manual repair.
I'm not sure what you're proposing here ... are you saying that the user
would have to modify the source cluster before pg_upgrade accepts to
run? That sounds pretty catastrophic.
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On Wed, Sep 11, 2019 at 06:25:38PM -0300, �lvaro Herrera wrote:
On 2019-Aug-21, Bruce Momjian wrote:
1) How exactly should we report this incompatibility to a user?
I think it's fine to leave the warnings and also write some hint for the
user by analogy with other checks.
"Reset ACL on the problem functions to default in the old cluster to
continue"Yes, I think it is good to at least throw an error during --check so
they don't have to find out during a live upgrade. Odds are it will
require manual repair.I'm not sure what you're proposing here ... are you saying that the user
would have to modify the source cluster before pg_upgrade accepts to
run? That sounds pretty catastrophic.
Well, right now, pg_upgrade --check succeeds, but the upgrade fails. I
am proposing, at a minimum, that pg_upgrade --check fails in such cases,
with a clear error message about how to fix it.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
On 2019-Sep-26, Bruce Momjian wrote:
On Wed, Sep 11, 2019 at 06:25:38PM -0300, �lvaro Herrera wrote:
On 2019-Aug-21, Bruce Momjian wrote:
1) How exactly should we report this incompatibility to a user?
I think it's fine to leave the warnings and also write some hint for the
user by analogy with other checks.
"Reset ACL on the problem functions to default in the old cluster to
continue"Yes, I think it is good to at least throw an error during --check so
they don't have to find out during a live upgrade. Odds are it will
require manual repair.I'm not sure what you're proposing here ... are you saying that the user
would have to modify the source cluster before pg_upgrade accepts to
run? That sounds pretty catastrophic.Well, right now, pg_upgrade --check succeeds, but the upgrade fails. I
am proposing, at a minimum, that pg_upgrade --check fails in such cases,
Agreed, that should be a minimum fix.
with a clear error message about how to fix it.
So the best solution being proposed is to reset the ACL to the default?
So we would be forcing the user to propagate the ACL change manually,
rather than trying to make pg_upgrade propagate it automatically. I
suppose making pg_upgrade would be better, but I'm not sure to what
extent that is a full solution.
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On Thu, Sep 26, 2019 at 05:16:19PM -0300, Alvaro Herrera wrote:
On 2019-Sep-26, Bruce Momjian wrote:
Well, right now, pg_upgrade --check succeeds, but the upgrade fails. I
am proposing, at a minimum, that pg_upgrade --check fails in such cases,Agreed, that should be a minimum fix.
Yes.
with a clear error message about how to fix it.
So the best solution being proposed is to reset the ACL to the default?
So we would be forcing the user to propagate the ACL change manually,
rather than trying to make pg_upgrade propagate it automatically. I
suppose making pg_upgrade would be better, but I'm not sure to what
extent that is a full solution.
Me neither, which is why I was proposing the minimum fix. We might not
know how to fix it in all case, but maybe we can detect all cases.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
On Thu, Sep 26, 2019 at 04:19:38PM -0400, Bruce Momjian wrote:
On Thu, Sep 26, 2019 at 05:16:19PM -0300, Alvaro Herrera wrote:
On 2019-Sep-26, Bruce Momjian wrote:
Well, right now, pg_upgrade --check succeeds, but the upgrade fails. I
am proposing, at a minimum, that pg_upgrade --check fails in such cases,Agreed, that should be a minimum fix.
Yes.
Agreed as well here. At least the latest patch proposed has the merit
to track automatically functions not existing anymore from the
source's version to the target's version, so patching --check offers a
good compromise. Bruce, are you planning to look more at the patch
posted at [1]/messages/by-id/392ca335-068d-7bd3-0ad8-fdf0a45d95d4@postgrespro.ru -- Michael?
[1]: /messages/by-id/392ca335-068d-7bd3-0ad8-fdf0a45d95d4@postgrespro.ru -- Michael
--
Michael
On Fri, Sep 27, 2019 at 04:22:15PM +0900, Michael Paquier wrote:
On Thu, Sep 26, 2019 at 04:19:38PM -0400, Bruce Momjian wrote:
On Thu, Sep 26, 2019 at 05:16:19PM -0300, Alvaro Herrera wrote:
On 2019-Sep-26, Bruce Momjian wrote:
Well, right now, pg_upgrade --check succeeds, but the upgrade fails. I
am proposing, at a minimum, that pg_upgrade --check fails in such cases,Agreed, that should be a minimum fix.
Yes.
Agreed as well here. At least the latest patch proposed has the merit
to track automatically functions not existing anymore from the
source's version to the target's version, so patching --check offers a
good compromise. Bruce, are you planning to look more at the patch
posted at [1]?
I did look at it. It has some TODO items listed in it still, and some
C++ comments, but if everyone likes it I can apply it.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
27.09.2019 15:51, Bruce Momjian wrote:
On Fri, Sep 27, 2019 at 04:22:15PM +0900, Michael Paquier wrote:
On Thu, Sep 26, 2019 at 04:19:38PM -0400, Bruce Momjian wrote:
On Thu, Sep 26, 2019 at 05:16:19PM -0300, Alvaro Herrera wrote:
On 2019-Sep-26, Bruce Momjian wrote:
Well, right now, pg_upgrade --check succeeds, but the upgrade fails. I
am proposing, at a minimum, that pg_upgrade --check fails in such cases,Agreed, that should be a minimum fix.
Yes.
Agreed as well here. At least the latest patch proposed has the merit
to track automatically functions not existing anymore from the
source's version to the target's version, so patching --check offers a
good compromise. Bruce, are you planning to look more at the patch
posted at [1]?I did look at it. It has some TODO items listed in it still, and some
C++ comments, but if everyone likes it I can apply it.
Cool. It seems that everyone agrees on this patch.
I attached the updated version. Now it prints a better error message
and generates an SQL script instead of multiple warnings. The attached
test script shows that.
Patches for 10, 11, and 12 slightly differ due to merge conflicts, so I
attached multiple versions.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v2_REL10.patchtext/x-patch; name=pg_upgrade_ACL_check_v2_REL10.patchDownload
commit dc6d9246c6255bed2bdb2e850a21bb1fc5e0c2fc
Author: Anastasia <a.lubennikova@postgrespro.ru>
Date: Fri Oct 4 14:39:54 2019 +0300
pg_upgrade_ACL_check_v2
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index e28b661..bfe9bbb 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -90,6 +90,7 @@ check_and_dump_old_cluster(bool live_check)
get_loadable_libraries();
+ get_catalog_procedures(&old_cluster);
/*
* Check for various failure cases
@@ -149,6 +150,16 @@ check_new_cluster(void)
check_loadable_libraries();
+ /*
+ * When restoring non-default ACL from old cluster we may attempt to apply
+ * GRANT for functions whose signatures have changed significantly.
+ *
+ * Compare function lists of old cluster and new cluster to catch
+ * the incompatibility early and report it to user with a nice error message
+ */
+ get_catalog_procedures(&new_cluster);
+ check_catalog_procedures(&old_cluster, &new_cluster);
+
if (user_opts.transfer_mode == TRANSFER_MODE_LINK)
check_hard_link();
diff --git a/src/bin/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c
index 063a94f..0fce929 100644
--- a/src/bin/pg_upgrade/function.c
+++ b/src/bin/pg_upgrade/function.c
@@ -13,6 +13,7 @@
#include "access/transam.h"
#include "catalog/pg_language.h"
+#include "fe_utils/string_utils.h"
/*
@@ -275,3 +276,204 @@ check_loadable_libraries(void)
else
check_ok();
}
+
+/*
+ * qsort comparator for procedure signatures
+ */
+static int
+proc_compare_sig(const void *p1, const void *p2)
+{
+ ProcInfo *proc1 = (ProcInfo *) p1;
+ ProcInfo *proc2 = (ProcInfo *) p2;
+
+ return strcmp(proc1->procsig, proc2->procsig);
+}
+
+/*
+ * Fetch the signatures and ACL of cluster's system procedures.
+ */
+void
+get_catalog_procedures(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ /*
+ * Fetch all procedure signatures and ACL.
+ * Each procedure may have different ACL in different database.
+ */
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ int num_procs;
+ int rowno;
+
+ /*
+ * Fetch procedure signatures and ACL of functions that have
+ * some non default ACL.
+ */
+ if (cluster->major_version >= 110000)
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(pg_proc.oid)::text"
+ " || ')' as funsig,"
+ " array (SELECT unnest(pg_proc.proacl)"
+ " EXCEPT SELECT unnest(pg_init_privs.initprivs))"
+ " from pg_proc join pg_init_privs"
+ " on pg_proc.oid = pg_init_privs.objoid"
+ " where prokind='f' and proacl != initprivs;");
+ }
+ else
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(pg_proc.oid)::text"
+ " || ')' as funsig,"
+ " array (SELECT unnest(pg_proc.proacl)"
+ " EXCEPT SELECT unnest(pg_init_privs.initprivs))"
+ " from pg_proc join pg_init_privs"
+ " on pg_proc.oid = pg_init_privs.objoid"
+ " where proisagg = false and proacl != initprivs;");
+ }
+
+ num_procs = PQntuples(res);
+ dbinfo->proc_arr.nprocs = num_procs;
+ dbinfo->proc_arr.procs = (ProcInfo *) pg_malloc(sizeof(ProcInfo) * num_procs);
+
+ for (rowno = 0; rowno < num_procs; rowno++)
+ {
+ ProcInfo *curr = &dbinfo->proc_arr.procs[rowno];
+ char *procsig = PQgetvalue(res, rowno, 0);
+ char *procacl = PQgetvalue(res, rowno, 1);
+
+ curr->procsig = pg_strdup(procsig);
+ curr->procacl = pg_strdup(procacl);
+ }
+
+ qsort((void *) dbinfo->proc_arr.procs, dbinfo->proc_arr.nprocs,
+ sizeof(ProcInfo), proc_compare_sig);
+
+ PQclear(res);
+ PQfinish(conn);
+ }
+}
+
+/* helper for check_catalog_procedures() */
+static void
+log_incompatible_procedure(FILE **script, char *output_path,
+ DbInfo *olddbinfo, bool *new_db,
+ ProcInfo *curr)
+{
+ char **aclitems;
+ int naclitems;
+ int i;
+
+ if (*script == NULL && (*script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n", output_path, strerror(errno));
+
+ if (*new_db)
+ {
+ fprintf(*script, _("\\c %s \n"), olddbinfo->db_name);
+ *new_db = false;
+ }
+
+ if (!parsePGArray(curr->procacl, &aclitems, &naclitems))
+ {
+ if (aclitems)
+ free(aclitems);
+ pg_fatal("check_catalog_procedures failed \n");
+ }
+
+ /* generate REVOKE command for each ACL on this function */
+ for (i = 0; i < naclitems; i++)
+ {
+ char *pos = strchr(aclitems[i], '=');
+ *pos = '\0';
+
+ if (pos != aclitems[i])
+ fprintf(*script, _("REVOKE ALL ON FUNCTION %s FROM %s;\n"),
+ curr->procsig, aclitems[i]);
+ else
+ fprintf(*script, _("REVOKE ALL ON FUNCTION %s FROM PUBLIC;\n"),
+ curr->procsig);
+ }
+}
+
+/*
+ * Check API changes in pg_proc between old_cluster and new_cluster.
+ * Report functions that only exist in old_cluster.
+ *
+ * NOTE It's vital to call it after check_databases_are_compatible(),
+ * because we rely on correct database order.
+ */
+void
+check_catalog_procedures(ClusterInfo *old_cluster, ClusterInfo *new_cluster)
+{
+ int dbnum;
+ FILE *script = NULL;
+ bool found = false;
+ char output_path[MAXPGPATH];
+ snprintf(output_path, sizeof(output_path), "catalog_procedures.sql");
+
+ prep_status("Checking for system functions API compatibility\n");
+
+ for (dbnum = 0; dbnum < old_cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *olddbinfo = &old_cluster->dbarr.dbs[dbnum];
+ DbInfo *newdbinfo = &new_cluster->dbarr.dbs[dbnum];
+ int i, j;
+ bool new_db = true;
+
+ if (strcmp(olddbinfo->db_name, newdbinfo->db_name) != 0)
+ pg_log(PG_FATAL, "check_catalog_procedures failed \n");
+
+ i = j = 0;
+ while (i < olddbinfo->proc_arr.nprocs && j < newdbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+ ProcInfo *newcurr = &newdbinfo->proc_arr.procs[j];
+ int result = strcmp(oldcurr->procsig, newcurr->procsig);
+
+ if (result == 0) /* The function exists in both clusters */
+ {
+ i++;
+ j++;
+ }
+ else if (result < 0) /* The function exists only in the old cluster */
+ {
+ log_incompatible_procedure(&script, output_path,
+ olddbinfo, &new_db, oldcurr);
+ found = true;
+ i++;
+ }
+ else if (result > 0) /* The function exists only in the new cluster */
+ j++;
+ }
+
+ /* handle tail of old_cluster proc list */
+ while (i < olddbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+ /* The function exists only in the old cluster */
+ log_incompatible_procedure(&script, output_path,
+ olddbinfo, &new_db, oldcurr);
+ found = true;
+
+ i++;
+ }
+ }
+
+ if (found)
+ {
+ fclose(script);
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default ACL on system procedures,\n"
+ "which API have changed between versions. To perform upgrade, reset ACL to default.\n"
+ "Script to REVOKE ALL on problem fuctions is in the file:\n"
+ " %s\n\n", output_path);
+ }
+ else
+ check_ok();
+}
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index dccc3e3..b33862c 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -155,6 +155,19 @@ typedef struct
int nrels;
} RelInfoArr;
+typedef struct
+{
+ char *procsig; /* procedure signature */
+ char *procacl; /* ACL */
+} ProcInfo;
+
+typedef struct
+{
+ ProcInfo *procs;
+ int nprocs;
+} ProcInfoArr;
+
+
/*
* The following structure represents a relation mapping.
*/
@@ -191,6 +204,7 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ ProcInfoArr proc_arr; /* array of system procedures */
} DbInfo;
typedef struct
@@ -382,6 +396,9 @@ void check_hard_link(void);
void get_loadable_libraries(void);
void check_loadable_libraries(void);
+void get_catalog_procedures(ClusterInfo *cluster);
+void check_catalog_procedures(ClusterInfo *old_cluster,
+ ClusterInfo *new_cluster);
/* info.c */
pg_upgrade_ACL_check_v2_REL11.patchtext/x-patch; name=pg_upgrade_ACL_check_v2_REL11.patchDownload
commit 515d895c599cb159b1f06d23b2027f72be6c5320
Author: Anastasia <a.lubennikova@postgrespro.ru>
Date: Thu Oct 3 13:50:54 2019 +0300
pg_upgrade_ACL_check_v2
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index b4cf6da..1ac3436 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -90,6 +90,7 @@ check_and_dump_old_cluster(bool live_check)
get_loadable_libraries();
+ get_catalog_procedures(&old_cluster);
/*
* Check for various failure cases
@@ -149,6 +150,16 @@ check_new_cluster(void)
check_loadable_libraries();
+ /*
+ * When restoring non-default ACL from old cluster we may attempt to apply
+ * GRANT for functions whose signatures have changed significantly.
+ *
+ * Compare function lists of old cluster and new cluster to catch
+ * the incompatibility early and report it to user with a nice error message
+ */
+ get_catalog_procedures(&new_cluster);
+ check_catalog_procedures(&old_cluster, &new_cluster);
+
if (user_opts.transfer_mode == TRANSFER_MODE_LINK)
check_hard_link();
diff --git a/src/bin/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c
index 03fd155..8a43bf6 100644
--- a/src/bin/pg_upgrade/function.c
+++ b/src/bin/pg_upgrade/function.c
@@ -13,6 +13,7 @@
#include "access/transam.h"
#include "catalog/pg_language_d.h"
+#include "fe_utils/string_utils.h"
/*
@@ -275,3 +276,204 @@ check_loadable_libraries(void)
else
check_ok();
}
+
+/*
+ * qsort comparator for procedure signatures
+ */
+static int
+proc_compare_sig(const void *p1, const void *p2)
+{
+ ProcInfo *proc1 = (ProcInfo *) p1;
+ ProcInfo *proc2 = (ProcInfo *) p2;
+
+ return strcmp(proc1->procsig, proc2->procsig);
+}
+
+/*
+ * Fetch the signatures and ACL of cluster's system procedures.
+ */
+void
+get_catalog_procedures(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ /*
+ * Fetch all procedure signatures and ACL.
+ * Each procedure may have different ACL in different database.
+ */
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ int num_procs;
+ int rowno;
+
+ /*
+ * Fetch procedure signatures and ACL of functions that have
+ * some non default ACL.
+ */
+ if (cluster->major_version >= 110000)
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(pg_proc.oid)::text"
+ " || ')' as funsig,"
+ " array (SELECT unnest(pg_proc.proacl)"
+ " EXCEPT SELECT unnest(pg_init_privs.initprivs))"
+ " from pg_proc join pg_init_privs"
+ " on pg_proc.oid = pg_init_privs.objoid"
+ " where prokind='f' and proacl != initprivs;");
+ }
+ else
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(pg_proc.oid)::text"
+ " || ')' as funsig,"
+ " array (SELECT unnest(pg_proc.proacl)"
+ " EXCEPT SELECT unnest(pg_init_privs.initprivs))"
+ " from pg_proc join pg_init_privs"
+ " on pg_proc.oid = pg_init_privs.objoid"
+ " where proisagg = false and proacl != initprivs;");
+ }
+
+ num_procs = PQntuples(res);
+ dbinfo->proc_arr.nprocs = num_procs;
+ dbinfo->proc_arr.procs = (ProcInfo *) pg_malloc(sizeof(ProcInfo) * num_procs);
+
+ for (rowno = 0; rowno < num_procs; rowno++)
+ {
+ ProcInfo *curr = &dbinfo->proc_arr.procs[rowno];
+ char *procsig = PQgetvalue(res, rowno, 0);
+ char *procacl = PQgetvalue(res, rowno, 1);
+
+ curr->procsig = pg_strdup(procsig);
+ curr->procacl = pg_strdup(procacl);
+ }
+
+ qsort((void *) dbinfo->proc_arr.procs, dbinfo->proc_arr.nprocs,
+ sizeof(ProcInfo), proc_compare_sig);
+
+ PQclear(res);
+ PQfinish(conn);
+ }
+}
+
+/* helper for check_catalog_procedures() */
+static void
+log_incompatible_procedure(FILE **script, char *output_path,
+ DbInfo *olddbinfo, bool *new_db,
+ ProcInfo *curr)
+{
+ char **aclitems;
+ int naclitems;
+ int i;
+
+ if (*script == NULL && (*script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n", output_path, strerror(errno));
+
+ if (*new_db)
+ {
+ fprintf(*script, _("\\c %s \n"), olddbinfo->db_name);
+ *new_db = false;
+ }
+
+ if (!parsePGArray(curr->procacl, &aclitems, &naclitems))
+ {
+ if (aclitems)
+ free(aclitems);
+ pg_fatal("check_catalog_procedures failed \n");
+ }
+
+ /* generate REVOKE command for each ACL on this function */
+ for (i = 0; i < naclitems; i++)
+ {
+ char *pos = strchr(aclitems[i], '=');
+ *pos = '\0';
+
+ if (pos != aclitems[i])
+ fprintf(*script, _("REVOKE ALL ON FUNCTION %s FROM %s;\n"),
+ curr->procsig, aclitems[i]);
+ else
+ fprintf(*script, _("REVOKE ALL ON FUNCTION %s FROM PUBLIC;\n"),
+ curr->procsig);
+ }
+}
+
+/*
+ * Check API changes in pg_proc between old_cluster and new_cluster.
+ * Report functions that only exist in old_cluster.
+ *
+ * NOTE It's vital to call it after check_databases_are_compatible(),
+ * because we rely on correct database order.
+ */
+void
+check_catalog_procedures(ClusterInfo *old_cluster, ClusterInfo *new_cluster)
+{
+ int dbnum;
+ FILE *script = NULL;
+ bool found = false;
+ char output_path[MAXPGPATH];
+ snprintf(output_path, sizeof(output_path), "catalog_procedures.sql");
+
+ prep_status("Checking for system functions API compatibility\n");
+
+ for (dbnum = 0; dbnum < old_cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *olddbinfo = &old_cluster->dbarr.dbs[dbnum];
+ DbInfo *newdbinfo = &new_cluster->dbarr.dbs[dbnum];
+ int i, j;
+ bool new_db = true;
+
+ if (strcmp(olddbinfo->db_name, newdbinfo->db_name) != 0)
+ pg_log(PG_FATAL, "check_catalog_procedures failed \n");
+
+ i = j = 0;
+ while (i < olddbinfo->proc_arr.nprocs && j < newdbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+ ProcInfo *newcurr = &newdbinfo->proc_arr.procs[j];
+ int result = strcmp(oldcurr->procsig, newcurr->procsig);
+
+ if (result == 0) /* The function exists in both clusters */
+ {
+ i++;
+ j++;
+ }
+ else if (result < 0) /* The function exists only in the old cluster */
+ {
+ log_incompatible_procedure(&script, output_path,
+ olddbinfo, &new_db, oldcurr);
+ found = true;
+ i++;
+ }
+ else if (result > 0) /* The function exists only in the new cluster */
+ j++;
+ }
+
+ /* handle tail of old_cluster proc list */
+ while (i < olddbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+ /* The function exists only in the old cluster */
+ log_incompatible_procedure(&script, output_path,
+ olddbinfo, &new_db, oldcurr);
+ found = true;
+
+ i++;
+ }
+ }
+
+ if (found)
+ {
+ fclose(script);
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default ACL on system procedures,\n"
+ "which API have changed between versions. To perform upgrade, reset ACL to default.\n"
+ "Script to REVOKE ALL on problem fuctions is in the file:\n"
+ " %s\n\n", output_path);
+ }
+ else
+ check_ok();
+}
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 7e5e971..5ed4f8e 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -155,6 +155,19 @@ typedef struct
int nrels;
} RelInfoArr;
+typedef struct
+{
+ char *procsig; /* procedure signature */
+ char *procacl; /* ACL */
+} ProcInfo;
+
+typedef struct
+{
+ ProcInfo *procs;
+ int nprocs;
+} ProcInfoArr;
+
+
/*
* The following structure represents a relation mapping.
*/
@@ -191,6 +204,7 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ ProcInfoArr proc_arr; /* array of system procedures */
} DbInfo;
typedef struct
@@ -382,6 +396,9 @@ void check_hard_link(void);
void get_loadable_libraries(void);
void check_loadable_libraries(void);
+void get_catalog_procedures(ClusterInfo *cluster);
+void check_catalog_procedures(ClusterInfo *old_cluster,
+ ClusterInfo *new_cluster);
/* info.c */
pg_upgrade_ACL_check_v2_REL12.patchtext/x-patch; name=pg_upgrade_ACL_check_v2_REL12.patchDownload
commit 2a13cd12afd28368a26898dd1e19f17b08bb1c45
Author: Anastasia <a.lubennikova@postgrespro.ru>
Date: Fri Oct 4 14:43:45 2019 +0300
pg_upgrade_ACL_check_v2
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 617270f..1c7a34a 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -91,6 +91,7 @@ check_and_dump_old_cluster(bool live_check)
get_loadable_libraries();
+ get_catalog_procedures(&old_cluster);
/*
* Check for various failure cases
@@ -157,6 +158,16 @@ check_new_cluster(void)
check_loadable_libraries();
+ /*
+ * When restoring non-default ACL from old cluster we may attempt to apply
+ * GRANT for functions whose signatures have changed significantly.
+ *
+ * Compare function lists of old cluster and new cluster to catch
+ * the incompatibility early and report it to user with a nice error message
+ */
+ get_catalog_procedures(&new_cluster);
+ check_catalog_procedures(&old_cluster, &new_cluster);
+
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c
index 0c66d1c..a5f8232 100644
--- a/src/bin/pg_upgrade/function.c
+++ b/src/bin/pg_upgrade/function.c
@@ -13,6 +13,7 @@
#include "access/transam.h"
#include "catalog/pg_language_d.h"
+#include "fe_utils/string_utils.h"
/*
@@ -275,3 +276,204 @@ check_loadable_libraries(void)
else
check_ok();
}
+
+/*
+ * qsort comparator for procedure signatures
+ */
+static int
+proc_compare_sig(const void *p1, const void *p2)
+{
+ ProcInfo *proc1 = (ProcInfo *) p1;
+ ProcInfo *proc2 = (ProcInfo *) p2;
+
+ return strcmp(proc1->procsig, proc2->procsig);
+}
+
+/*
+ * Fetch the signatures and ACL of cluster's system procedures.
+ */
+void
+get_catalog_procedures(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ /*
+ * Fetch all procedure signatures and ACL.
+ * Each procedure may have different ACL in different database.
+ */
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ int num_procs;
+ int rowno;
+
+ /*
+ * Fetch procedure signatures and ACL of functions that have
+ * some non default ACL.
+ */
+ if (cluster->major_version >= 110000)
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(pg_proc.oid)::text"
+ " || ')' as funsig,"
+ " array (SELECT unnest(pg_proc.proacl)"
+ " EXCEPT SELECT unnest(pg_init_privs.initprivs))"
+ " from pg_proc join pg_init_privs"
+ " on pg_proc.oid = pg_init_privs.objoid"
+ " where prokind='f' and proacl != initprivs;");
+ }
+ else
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(pg_proc.oid)::text"
+ " || ')' as funsig,"
+ " array (SELECT unnest(pg_proc.proacl)"
+ " EXCEPT SELECT unnest(pg_init_privs.initprivs))"
+ " from pg_proc join pg_init_privs"
+ " on pg_proc.oid = pg_init_privs.objoid"
+ " where proisagg = false and proacl != initprivs;");
+ }
+
+ num_procs = PQntuples(res);
+ dbinfo->proc_arr.nprocs = num_procs;
+ dbinfo->proc_arr.procs = (ProcInfo *) pg_malloc(sizeof(ProcInfo) * num_procs);
+
+ for (rowno = 0; rowno < num_procs; rowno++)
+ {
+ ProcInfo *curr = &dbinfo->proc_arr.procs[rowno];
+ char *procsig = PQgetvalue(res, rowno, 0);
+ char *procacl = PQgetvalue(res, rowno, 1);
+
+ curr->procsig = pg_strdup(procsig);
+ curr->procacl = pg_strdup(procacl);
+ }
+
+ qsort((void *) dbinfo->proc_arr.procs, dbinfo->proc_arr.nprocs,
+ sizeof(ProcInfo), proc_compare_sig);
+
+ PQclear(res);
+ PQfinish(conn);
+ }
+}
+
+/* helper for check_catalog_procedures() */
+static void
+log_incompatible_procedure(FILE **script, char *output_path,
+ DbInfo *olddbinfo, bool *new_db,
+ ProcInfo *curr)
+{
+ char **aclitems;
+ int naclitems;
+ int i;
+
+ if (*script == NULL && (*script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n", output_path, strerror(errno));
+
+ if (*new_db)
+ {
+ fprintf(*script, _("\\c %s \n"), olddbinfo->db_name);
+ *new_db = false;
+ }
+
+ if (!parsePGArray(curr->procacl, &aclitems, &naclitems))
+ {
+ if (aclitems)
+ free(aclitems);
+ pg_fatal("check_catalog_procedures failed \n");
+ }
+
+ /* generate REVOKE command for each ACL on this function */
+ for (i = 0; i < naclitems; i++)
+ {
+ char *pos = strchr(aclitems[i], '=');
+ *pos = '\0';
+
+ if (pos != aclitems[i])
+ fprintf(*script, _("REVOKE ALL ON FUNCTION %s FROM %s;\n"),
+ curr->procsig, aclitems[i]);
+ else
+ fprintf(*script, _("REVOKE ALL ON FUNCTION %s FROM PUBLIC;\n"),
+ curr->procsig);
+ }
+}
+
+/*
+ * Check API changes in pg_proc between old_cluster and new_cluster.
+ * Report functions that only exist in old_cluster.
+ *
+ * NOTE It's vital to call it after check_databases_are_compatible(),
+ * because we rely on correct database order.
+ */
+void
+check_catalog_procedures(ClusterInfo *old_cluster, ClusterInfo *new_cluster)
+{
+ int dbnum;
+ FILE *script = NULL;
+ bool found = false;
+ char output_path[MAXPGPATH];
+ snprintf(output_path, sizeof(output_path), "catalog_procedures.sql");
+
+ prep_status("Checking for system functions API compatibility\n");
+
+ for (dbnum = 0; dbnum < old_cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *olddbinfo = &old_cluster->dbarr.dbs[dbnum];
+ DbInfo *newdbinfo = &new_cluster->dbarr.dbs[dbnum];
+ int i, j;
+ bool new_db = true;
+
+ if (strcmp(olddbinfo->db_name, newdbinfo->db_name) != 0)
+ pg_log(PG_FATAL, "check_catalog_procedures failed \n");
+
+ i = j = 0;
+ while (i < olddbinfo->proc_arr.nprocs && j < newdbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+ ProcInfo *newcurr = &newdbinfo->proc_arr.procs[j];
+ int result = strcmp(oldcurr->procsig, newcurr->procsig);
+
+ if (result == 0) /* The function exists in both clusters */
+ {
+ i++;
+ j++;
+ }
+ else if (result < 0) /* The function exists only in the old cluster */
+ {
+ log_incompatible_procedure(&script, output_path,
+ olddbinfo, &new_db, oldcurr);
+ found = true;
+ i++;
+ }
+ else if (result > 0) /* The function exists only in the new cluster */
+ j++;
+ }
+
+ /* handle tail of old_cluster proc list */
+ while (i < olddbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+ /* The function exists only in the old cluster */
+ log_incompatible_procedure(&script, output_path,
+ olddbinfo, &new_db, oldcurr);
+ found = true;
+
+ i++;
+ }
+ }
+
+ if (found)
+ {
+ fclose(script);
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default ACL on system procedures,\n"
+ "which API have changed between versions. To perform upgrade, reset ACL to default.\n"
+ "Script to REVOKE ALL on problem fuctions is in the file:\n"
+ " %s\n\n", output_path);
+ }
+ else
+ check_ok();
+}
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 5d31750..97db9e5 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -155,6 +155,19 @@ typedef struct
int nrels;
} RelInfoArr;
+typedef struct
+{
+ char *procsig; /* procedure signature */
+ char *procacl; /* ACL */
+} ProcInfo;
+
+typedef struct
+{
+ ProcInfo *procs;
+ int nprocs;
+} ProcInfoArr;
+
+
/*
* The following structure represents a relation mapping.
*/
@@ -191,6 +204,7 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ ProcInfoArr proc_arr; /* array of system procedures */
} DbInfo;
typedef struct
@@ -392,6 +406,9 @@ void check_hard_link(void);
void get_loadable_libraries(void);
void check_loadable_libraries(void);
+void get_catalog_procedures(ClusterInfo *cluster);
+void check_catalog_procedures(ClusterInfo *old_cluster,
+ ClusterInfo *new_cluster);
/* info.c */
Greetings,
* Anastasia Lubennikova (a.lubennikova@postgrespro.ru) wrote:
Cool. It seems that everyone agrees on this patch.
Thanks for working on this, I took a quick look over it and I do have
some concerns.
I attached the updated version. Now it prints a better error message
and generates an SQL script instead of multiple warnings. The attached test
script shows that.
Have you tested this with extensions, where the user has changed the
privileges on the extension? I'm concerned that we'll throw out
warnings and tell users to go REVOKE privileges on any case where the
privileges on an extension's object were changed, but that shouldn't be
necessary and we should be excluding those.
Changes to privileges on extensions should be handled just fine using
the existing code, at least for upgrades of PG.
Otherwise, at least imv, the code could use more comments (inside the
functions, not just function-level...) and there's a few wording
improvements that could be made. Again, not a full endorsement, as I
just took a quick look, but it generally seems like a reasonable
approach to go in and the issue with extensions was the only thing that
came to mind as a potential problem.
Thanks,
Stephen
08.10.2019 17:08, Stephen Frost wrote:
I attached the updated version. Now it prints a better error message
and generates an SQL script instead of multiple warnings. The attached test
script shows that.Have you tested this with extensions, where the user has changed the
privileges on the extension? I'm concerned that we'll throw out
warnings and tell users to go REVOKE privileges on any case where the
privileges on an extension's object were changed, but that shouldn't be
necessary and we should be excluding those.
Good catch.
Fixed in v3.
I also added this check to previous test script. It passes with both v2
and v3,
but v3 doesn't throw unneeded warning for extension functions.
Changes to privileges on extensions should be handled just fine using
the existing code, at least for upgrades of PG.Otherwise, at least imv, the code could use more comments (inside the
functions, not just function-level...) and there's a few wording
improvements that could be made. Again, not a full endorsement, as I
just took a quick look, but it generally seems like a reasonable
approach to go in and the issue with extensions was the only thing that
came to mind as a potential problem.
I added more comments and updated the error message.
Please, feel free to fix them, if you have any suggestions.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v3_master.patchtext/x-patch; name=pg_upgrade_ACL_check_v3_master.patchDownload
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index ff7057d..623a05e 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -90,6 +90,7 @@ check_and_dump_old_cluster(bool live_check)
get_loadable_libraries();
+ get_catalog_procedures(&old_cluster);
/*
* Check for various failure cases
@@ -164,6 +165,16 @@ check_new_cluster(void)
check_loadable_libraries();
+ /*
+ * When restoring non-default ACL from old cluster we may attempt to apply
+ * GRANT for functions whose signatures have changed significantly.
+ *
+ * Compare function lists of old cluster and new cluster to catch
+ * the incompatibility early and report it to user with a nice error message
+ */
+ get_catalog_procedures(&new_cluster);
+ check_catalog_procedures(&old_cluster, &new_cluster);
+
switch (user_opts.transfer_mode)
{
case TRANSFER_MODE_CLONE:
diff --git a/src/bin/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c
index ac984db..324bfd4 100644
--- a/src/bin/pg_upgrade/function.c
+++ b/src/bin/pg_upgrade/function.c
@@ -12,6 +12,7 @@
#include "access/transam.h"
#include "catalog/pg_language_d.h"
#include "pg_upgrade.h"
+#include "fe_utils/string_utils.h"
/*
* qsort comparator for pointers to library names
@@ -273,3 +274,224 @@ check_loadable_libraries(void)
else
check_ok();
}
+
+/*
+ * qsort comparator for procedure signatures
+ */
+static int
+proc_compare_sig(const void *p1, const void *p2)
+{
+ ProcInfo *proc1 = (ProcInfo *) p1;
+ ProcInfo *proc2 = (ProcInfo *) p2;
+
+ return strcmp(proc1->procsig, proc2->procsig);
+}
+
+/*
+ * Fetch the signatures and ACL of cluster's system procedures.
+ */
+void
+get_catalog_procedures(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ /*
+ * Fetch all procedure signatures and ACL.
+ * Each procedure may have different ACL in different database.
+ */
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ int num_procs;
+ int rowno;
+
+ /*
+ * Fetch procedure signatures and ACL of functions that have
+ * non default ACL. For each procedure save only ACL that differs
+ * from initial privilleges. Only check privileges set by initdb.
+ * Objects which have initial privileges set by CREATE EXTENSION,
+ * will be handled by extension itself.
+ */
+ if (cluster->major_version >= 110000)
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(pg_proc.oid)::text"
+ " || ')' as funsig,"
+ " array (SELECT unnest(pg_proc.proacl)"
+ " EXCEPT SELECT unnest(pg_init_privs.initprivs))"
+ " from pg_proc join pg_init_privs"
+ " on pg_proc.oid = pg_init_privs.objoid"
+ " where pg_init_privs.classoid = 'pg_proc'::regclass::oid"
+ " and pg_init_privs.privtype = 'i'"
+ " and pg_proc.prokind='f'"
+ " and pg_proc.proacl != pg_init_privs.initprivs;");
+ }
+ else
+ {
+ res = executeQueryOrDie(conn,
+ "select proname::text || '('"
+ " || pg_get_function_arguments(pg_proc.oid)::text"
+ " || ')' as funsig,"
+ " array (SELECT unnest(pg_proc.proacl)"
+ " EXCEPT SELECT unnest(pg_init_privs.initprivs))"
+ " from pg_proc join pg_init_privs"
+ " on pg_proc.oid = pg_init_privs.objoid"
+ " where pg_init_privs.classoid = 'pg_proc'::regclass::oid"
+ " and pg_init_privs.privtype = 'i'"
+ " and pg_proc.proisagg = false"
+ " and pg_proc.proacl != pg_init_privs.initprivs;");
+ }
+
+ num_procs = PQntuples(res);
+ dbinfo->proc_arr.nprocs = num_procs;
+ dbinfo->proc_arr.procs = (ProcInfo *) pg_malloc(sizeof(ProcInfo) * num_procs);
+
+ for (rowno = 0; rowno < num_procs; rowno++)
+ {
+ ProcInfo *curr = &dbinfo->proc_arr.procs[rowno];
+ char *procsig = PQgetvalue(res, rowno, 0);
+ char *procacl = PQgetvalue(res, rowno, 1);
+
+ curr->procsig = pg_strdup(procsig);
+ curr->procacl = pg_strdup(procacl);
+ }
+
+ qsort((void *) dbinfo->proc_arr.procs, dbinfo->proc_arr.nprocs,
+ sizeof(ProcInfo), proc_compare_sig);
+
+ PQclear(res);
+ PQfinish(conn);
+ }
+}
+
+/* helper for check_catalog_procedures() */
+static void
+log_incompatible_procedure(FILE **script, char *output_path,
+ DbInfo *olddbinfo, bool *new_db,
+ ProcInfo *curr)
+{
+ char **aclitems;
+ int naclitems;
+ int i;
+
+ if (*script == NULL && (*script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n", output_path, strerror(errno));
+
+ /* REVOKE command must be executed in corresponding database */
+ if (*new_db)
+ {
+ fprintf(*script, _("\\c %s \n"), olddbinfo->db_name);
+ *new_db = false;
+ }
+
+ if (!parsePGArray(curr->procacl, &aclitems, &naclitems))
+ {
+ if (aclitems)
+ free(aclitems);
+ pg_fatal("check_catalog_procedures failed \n");
+ }
+
+ /* generate REVOKE command for each ACL on this function */
+ for (i = 0; i < naclitems; i++)
+ {
+ char *pos = strchr(aclitems[i], '=');
+ *pos = '\0';
+
+ if (pos != aclitems[i])
+ fprintf(*script, _("REVOKE ALL ON FUNCTION %s FROM %s;\n"),
+ curr->procsig, aclitems[i]);
+ else
+ fprintf(*script, _("REVOKE ALL ON FUNCTION %s FROM PUBLIC;\n"),
+ curr->procsig);
+ }
+
+ if (aclitems)
+ free(aclitems);
+}
+
+/*
+ * Check API changes in pg_proc between old_cluster and new_cluster.
+ * Report functions that only exist in old_cluster.
+ *
+ * NOTE It's vital to call it after check_databases_are_compatible(),
+ * because we rely on correct database order.
+ */
+void
+check_catalog_procedures(ClusterInfo *old_cluster, ClusterInfo *new_cluster)
+{
+ int dbnum;
+ FILE *script = NULL;
+ bool found = false;
+ char output_path[MAXPGPATH];
+ snprintf(output_path, sizeof(output_path), "catalog_procedures.sql");
+
+ prep_status("Checking for system functions API compatibility\n");
+
+ for (dbnum = 0; dbnum < old_cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *olddbinfo = &old_cluster->dbarr.dbs[dbnum];
+ DbInfo *newdbinfo = &new_cluster->dbarr.dbs[dbnum];
+ int i, j;
+ bool new_db = true;
+
+ if (strcmp(olddbinfo->db_name, newdbinfo->db_name) != 0)
+ pg_log(PG_FATAL, "check_catalog_procedures failed \n");
+
+ /*
+ * Check system functions with non-standard ACL from the old cluster
+ * against system functions from the new cluster. If the function
+ * only exist in the old cluster, generate REVOKE script to perform
+ * before upgrade. Both lists are sorted by procsig.
+ */
+ i = j = 0;
+ while (i < olddbinfo->proc_arr.nprocs && j < newdbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+ ProcInfo *newcurr = &newdbinfo->proc_arr.procs[j];
+ int result = strcmp(oldcurr->procsig, newcurr->procsig);
+
+ if (result == 0) /* The function exists in both clusters */
+ {
+ i++;
+ j++;
+ }
+ else if (result < 0) /* The function exists only in the old cluster */
+ {
+ log_incompatible_procedure(&script, output_path,
+ olddbinfo, &new_db, oldcurr);
+ found = true;
+ i++;
+ }
+ else if (result > 0) /* The function exists only in the new cluster */
+ j++;
+ }
+
+ /* handle tail of old_cluster proc list */
+ while (i < olddbinfo->proc_arr.nprocs)
+ {
+ ProcInfo *oldcurr = &olddbinfo->proc_arr.procs[i];
+ /* The function exists only in the old cluster */
+ log_incompatible_procedure(&script, output_path,
+ olddbinfo, &new_db, oldcurr);
+ found = true;
+
+ i++;
+ }
+ }
+
+ if (found)
+ {
+ fclose(script);
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges \n"
+ "for system procedures for which the API has changed. \n"
+ "To perform the upgrade, reset these privileges to default.\n"
+ "File %s contains the script to perform REVOKE ALL for such procedures.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 729f86a..41ded53 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -149,6 +149,19 @@ typedef struct
int nrels;
} RelInfoArr;
+typedef struct
+{
+ char *procsig; /* procedure signature */
+ char *procacl; /* ACL */
+} ProcInfo;
+
+typedef struct
+{
+ ProcInfo *procs;
+ int nprocs;
+} ProcInfoArr;
+
+
/*
* The following structure represents a relation mapping.
*/
@@ -185,6 +198,7 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ ProcInfoArr proc_arr; /* array of system procedures */
} DbInfo;
typedef struct
@@ -385,6 +399,9 @@ void check_hard_link(void);
void get_loadable_libraries(void);
void check_loadable_libraries(void);
+void get_catalog_procedures(ClusterInfo *cluster);
+void check_catalog_procedures(ClusterInfo *old_cluster,
+ ClusterInfo *new_cluster);
/* info.c */
On Mon, Oct 28, 2019 at 05:40:44PM +0300, Anastasia Lubennikova wrote:
I added more comments and updated the error message.
Please, feel free to fix them, if you have any suggestions.
I have begun looking at this one.
+ /* REVOKE command must be executed in corresponding database */
+ if (*new_db)
+ {
+ fprintf(*script, _("\\c %s \n"), olddbinfo->db_name);
+ *new_db = false;
+ }
This will fail if the database to use includes a space? And it seems
to me that log_incompatible_procedure() does not quote things
properly either.
+ * from initial privilleges. Only check privileges set by initdb.
s/privilleges/privileges/
I think that there is little point to keep get_catalog_procedures()
and check_catalog_procedures() separated. Why not just using a single
entry point.
Wouldn't it be more simple to just use a cast as
pg_proc.oid::regprocedure in the queries?
Let's also put some effort in the formatting of the SQL queries here:
- Schema-qualification with pg_catalog.
- Format of the clauses could be better (for examples two-space
indentation for clauses, etc.)
I think that we should keep the core part of the fix more simple by
just warning about missing function signatures in the target cluster
when pg_upgrade --check is used. So I think that it would be better
for now to get to a point where we can warn about the function
signatures involved in a given database, without the generation of the
script with those REVOKE queries. Or would folks prefer keep that in
the first version? My take would be to handle both separately, and to
warn about everything so as there is no need to do pg_upgrade --check
more than once.
I may be missing something, but it seems to me that there is no need
to attach proc_arr to DbInfo or have traces of it in pg_upgrade.h as
long as you keep the checks of function signatures local to the single
entry point I am mentioning above.
--
Michael
On Fri, Nov 08, 2019 at 06:03:06PM +0900, Michael Paquier wrote:
I have begun looking at this one.
Another question I have: do we need to care more about other extra
ACLs applied to other object types? For example a subset of columns
on a table with a column being renamed could be an issue. Procedure
renamed in core are not that common still we did it.
Here is another idea I have regarding this set of problems. We could
use pg_depend on the source for system objects and join it with
pg_init_privs, and then compare it with the entries of the target
based on the descriptions generated by pg_describe_object(). If there
is an object renamed or an unmatching signature, then we would
immediately find about it, for any object types.
--
Michael
HelLo!
On 11/9/19 5:26 AM, Michael Paquier wrote:
On Fri, Nov 08, 2019 at 06:03:06PM +0900, Michael Paquier wrote:
I have begun looking at this one.
Another question I have: do we need to care more about other extra
ACLs applied to other object types? For example a subset of columns
on a table with a column being renamed could be an issue. Procedure
renamed in core are not that common still we did it.
I think that all objects must be supported.
User application may depend on them, so silently casting them to the
void during upgrade may ruin someones day.
But also I think, that this work should be done piecemeal, to make
testing and reviewing easier, and functions are a good candidate for a
first go.
I think that we should keep the core part of the fix more simple by
just warning about missing function signatures in the target cluster
when pg_upgrade --check is used.
I think that warning without any concrete details on functions involved
is confusing.
So I think that it would be better
for now to get to a point where we can warn about the function
signatures involved in a given database, without the generation of the
script with those REVOKE queries. Or would folks prefer keep that in
the first version? My take would be to handle both separately, and to
warn about everything so as there is no need to do pg_upgrade --check
more than once.
I would prefer to warn about every function (so he can more quickly
assess the situation)� AND generate script. It is good to save some user
time, because he is going to need that script anyway.
I`ve tested the master patch:
1. upgrade from 9.5 and lower is broken:
[gsmol@deck upgrade_workdir]$ /home/gsmol/task/13_devel/bin/pg_upgrade
-b /home/gsmol/task/9.5.19/bin/ -B /home/gsmol/task/13_devel/bin/ -d
/home/gsmol/task/9.5.19/data -D /tmp/upgrade
Performing Consistency Checks
-----------------------------
Checking cluster versions���������������������������������� ok
SQL command failed
select proname::text || '(' ||
pg_get_function_arguments(pg_proc.oid)::text || ')' as funsig, array
(SELECT unnest(pg_proc.proacl) EXCEPT SELECT
unnest(pg_init_privs.initprivs)) from pg_proc join pg_init_privs on
pg_proc.oid = pg_init_privs.objoid where pg_init_privs.classoid =
'pg_proc'::regclass::oid and pg_init_privs.privtype = 'i' and
pg_proc.proisagg = false and pg_proc.proacl != pg_init_privs.initprivs;
ERROR:� relation "pg_init_privs" does not exist
LINE 1: ...nnest(pg_init_privs.initprivs)) from pg_proc join pg_init_pr...
������������������������������������������������������������ ^
Failure, exiting
2. I think that message "Your installation contains non-default
privileges for system procedures for which the API has changed." must
contain versions:
"Your PostgreSQL 9.5 installation contains non-default privileges for
system procedures for which the API has changed in PostgreSQL 12."
--
Grigory Smolkin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
On Fri, Nov 15, 2019 at 11:30:02AM +0300, Grigory Smolkin wrote:
On 11/9/19 5:26 AM, Michael Paquier wrote:
Another question I have: do we need to care more about other extra
ACLs applied to other object types? For example a subset of columns
on a table with a column being renamed could be an issue. Procedure
renamed in core are not that common still we did it.I think that all objects must be supported.
The unfortunate part about the current approach is that it is not
really scalable from the point of view of the client. What the patch
does is to compare the initdb-time ACLs and the ones stored in
pg_proc. In order to support all object types we would need to have
more client-side logic to join properly with all the catalogs holding
the ACLs of the objects to be compared. I am wondering if it would be
more simple to invent a backend function which uses an input similar
to pg_describe_object() with (classid, objid and objsubid) that
returns the ACL of the corresponding object after looking at the
catalog defined by classid. This would simplify the client part to
just scan pg_init_privs...
So I think that it would be better
for now to get to a point where we can warn about the function
signatures involved in a given database, without the generation of the
script with those REVOKE queries. Or would folks prefer keep that in
the first version? My take would be to handle both separately, and to
warn about everything so as there is no need to do pg_upgrade --check
more than once.I would prefer to warn about every function (so he can more quickly assess
the situation) AND generate script. It is good to save some user time,
because he is going to need that script anyway.
Not arguing against the fact that it is useful, but I'd think that it
is a two-step process, where we need to understand what logic needs to
be in the backend or some frontend:
1) Warn properly about the objects involved, where the object
description returned by pg_describe_object would be fine enough to
understand what's broken in a given database.
2) Generate a script which may be used by the end-user.
--
Michael
On Thu, Nov 21, 2019 at 05:53:16PM +0900, Michael Paquier wrote:
Not arguing against the fact that it is useful, but I'd think that it
is a two-step process, where we need to understand what logic needs to
be in the backend or some frontend:
1) Warn properly about the objects involved, where the object
description returned by pg_describe_object would be fine enough to
understand what's broken in a given database.
2) Generate a script which may be used by the end-user.
So, we have here a patch with no updates from the authors for the last
two months. Anastasia, Arthur, are you still interested in this
problem? Gregory has provided a review lately and has pointed out
some issues.
--
Michael
Thank you for reviews!
On 2019/11/21 17:53, Michael Paquier wrote:
On Fri, Nov 15, 2019 at 11:30:02AM +0300, Grigory Smolkin wrote:
On 11/9/19 5:26 AM, Michael Paquier wrote:
Another question I have: do we need to care more about other extra
ACLs applied to other object types? For example a subset of columns
on a table with a column being renamed could be an issue. Procedure
renamed in core are not that common still we did it.I think that all objects must be supported.
The unfortunate part about the current approach is that it is not
really scalable from the point of view of the client. What the patch
does is to compare the initdb-time ACLs and the ones stored in
pg_proc. In order to support all object types we would need to have
more client-side logic to join properly with all the catalogs holding
the ACLs of the objects to be compared. I am wondering if it would be
more simple to invent a backend function which uses an input similar
to pg_describe_object() with (classid, objid and objsubid) that
returns the ACL of the corresponding object after looking at the
catalog defined by classid. This would simplify the client part to
just scan pg_init_privs...
I've started to implement new backend function similar to
pg_describe_object() and tried to make new version of the patch. But I'm
wondering now if it is possible to backpatch new functions to older
Postgres releases? pg_upgrade will require a presence of this function
on an older source cluster.
Other approach is similar to Anastasia's patch, which is scanning
pg_proc, pg_class, pg_attribute and others to get modified ACL's and
compare it with initial ACL from pg_init_privs. Next step is to find
objects which names or signatures were changed using
pg_describe_object() and scanning pg_depend of new cluster (there is a
problem here though: there are no entries for relations columns).
--
Artur
On Wed, Nov 27, 2019 at 11:35:14AM +0900, Artur Zakirov wrote:
I've started to implement new backend function similar to
pg_describe_object() and tried to make new version of the patch. But I'm
wondering now if it is possible to backpatch new functions to older
Postgres releases? pg_upgrade will require a presence of this function on an
older source cluster.
New functions cannot be backpatched because it would require a catalog
bump.
Other approach is similar to Anastasia's patch, which is scanning pg_proc,
pg_class, pg_attribute and others to get modified ACL's and compare it with
initial ACL from pg_init_privs. Next step is to find objects which names or
signatures were changed using pg_describe_object() and scanning pg_depend of
new cluster
Yeah, the actual take is if we want to make the frontend code more
complicated with a large set of SQL queries to check that each object
ACL is modified, which adds an additional maintenance cost in
pg_upgrade. Or if we want to keep the frontend simple and have more
backend facility to ease cross-catalog lookups for ACLs. Perhaps we
could also live with just checking after the ACLs of functions in the
short term and perhaps it covers most of the cases users would care
about.. That's tricky to conclude about and I am not sure which path
is better in the long-term, but at least it's worth discussing all
possible candidates IMO so as we make sure to not miss anything.
(there is a problem here though: there are no entries for
relations columns).
When it comes to column ACLs, pg_shdepend stores a dependency between
the column's relation and the role.
--
Michael
On 2019/11/27 13:22, Michael Paquier wrote:
On Wed, Nov 27, 2019 at 11:35:14AM +0900, Artur Zakirov wrote:
Other approach is similar to Anastasia's patch, which is scanning pg_proc,
pg_class, pg_attribute and others to get modified ACL's and compare it with
initial ACL from pg_init_privs. Next step is to find objects which names or
signatures were changed using pg_describe_object() and scanning pg_depend of
new clusterYeah, the actual take is if we want to make the frontend code more
complicated with a large set of SQL queries to check that each object
ACL is modified, which adds an additional maintenance cost in
pg_upgrade. Or if we want to keep the frontend simple and have more
backend facility to ease cross-catalog lookups for ACLs. Perhaps we
could also live with just checking after the ACLs of functions in the
short term and perhaps it covers most of the cases users would care
about.. That's tricky to conclude about and I am not sure which path
is better in the long-term, but at least it's worth discussing all
possible candidates IMO so as we make sure to not miss anything.
I checked what objects changed their signatures between master and 9.6.
I just ran pg_describe_object() for grantable object types, saved the
output into a file and diffed the outputs. It seems that only functions
and table columns changed their signatures. A list of functions is big
and here the list of columns:
table pg_attrdef column adsrc
table pg_class column relhasoids
table pg_class column relhaspkey
table pg_constraint column consrc
table pg_proc column proisagg
table pg_proc column proiswindow
table pg_proc column protransform
As a result I think in pg_upgrade we could just check functions and
columns signatures. It might simplify the patch. And if something
changes in a future we could fix pg_upgrade too.
(there is a problem here though: there are no entries for
relations columns).When it comes to column ACLs, pg_shdepend stores a dependency between
the column's relation and the role.
Thank you for the hint. pg_shdepend could be used in a patch.
--
Artur
If Anastasia doesn't mind I'd like to send new version of the patch.
On 2019/11/28 12:29, Artur Zakirov wrote:
On 2019/11/27 13:22, Michael Paquier wrote:
Yeah, the actual take is if we want to make the frontend code more
complicated with a large set of SQL queries to check that each object
ACL is modified, which adds an additional maintenance cost in
pg_upgrade.� Or if we want to keep the frontend simple and have more
backend facility to ease cross-catalog lookups for ACLs.� Perhaps we
could also live with just checking after the ACLs of functions in the
short term and perhaps it covers most of the cases users would care
about..� That's tricky to conclude about and I am not sure which path
is better in the long-term, but at least it's worth discussing all
possible candidates IMO so as we make sure to not miss anything.I checked what objects changed their signatures between master and 9.6.
I just ran pg_describe_object() for grantable object types, saved the
output into a file and diffed the outputs. It seems that only functions
and table columns changed their signatures. A list of functions is big
and here the list of columns:table pg_attrdef column adsrc
table pg_class column relhasoids
table pg_class column relhaspkey
table pg_constraint column consrc
table pg_proc column proisagg
table pg_proc column proiswindow
table pg_proc column protransformAs a result I think in pg_upgrade we could just check functions and
columns signatures. It might simplify the patch. And if something
changes in a future we could fix pg_upgrade too.
New version of the patch differs from the previous:
- it doesn't generate script to revoke conflicting permissions (but the
patch can be fixed easily)
- generates file incompatible_objects_for_acl.txt to report which
objects changed their signatures
- uses pg_shdepend and pg_depend catalogs to get objects with custom
privileges
- uses pg_describe_object() to find objects with different signatures
Currently relations, attributes, languages, functions and procedures are
scanned. According to the documentation foreign databases, foreign-data
wrappers, foreign servers, schemas and tablespaces also support ACLs.
But some of them doesn't have entries initialized during initdb, others
like schemas and tablespaces didn't change their names. So the patch
doesn't scan such objects.
Grigory it would be great if you'll try the patch. I tested it but I
could miss something.
--
Artur
Attachments:
pg_upgrade_ACL_check_v4.patchtext/plain; charset=UTF-8; name=pg_upgrade_ACL_check_v4.patchDownload
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index cdd8788b9e..7120ead751 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -142,6 +142,9 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ if (user_opts.check)
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -181,6 +184,143 @@ check_new_cluster(void)
check_for_prepared_transactions(&new_cluster);
}
+/*
+ * check_changed_signatures()
+ *
+ * Checks that the old cluster doesn't have non-default ACL's for system objects
+ * which had different signatures in the new cluster.
+ */
+void
+check_changed_signatures(void)
+{
+ PGconn *conn;
+ PGresult *new_res;
+ int new_ntups;
+ int i_obj_sig = 0;
+ int dbnum;
+ bool need_check;
+ FILE *script = NULL;
+ bool found_incompatible = false;
+ char output_path[MAXPGPATH];
+
+ if (!user_opts.check)
+ return;
+
+ prep_status("Checking for system objects to grant or revoke privileges");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+ /*
+ * The old cluster doesn't have system objects with non-default ACL so
+ * quickly exit.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path),
+ "incompatible_objects_for_acl.txt");
+
+ conn = connectToServer(&new_cluster, "template1");
+ new_res = executeQueryOrDie(conn,
+ /* Get relations, languages, functions and procedures */
+ "SELECT pg_catalog.pg_describe_object(refclassid, refobjid, refobjsubid) "
+ "FROM pg_catalog.pg_depend "
+ "WHERE deptype = 'p' AND refclassid IN "
+ " ('pg_proc'::regclass, 'pg_class'::regclass, 'pg_language'::regclass) "
+ "UNION ALL "
+ /* ...and union it with columns */
+ "SELECT pg_catalog.pg_describe_object(d.refclassid, att.attrelid, att.attnum) "
+ "FROM pg_catalog.pg_depend d "
+ "INNER JOIN pg_catalog.pg_attribute att ON att.attrelid = d.refobjid "
+ "WHERE d.deptype = 'p' AND d.refclassid = 'pg_class'::regclass "
+ "ORDER BY 1;");
+ new_ntups = PQntuples(new_res);
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ new_objnum = 0;
+
+ /*
+ * For every database check system objects with non-default ACL.
+ *
+ * AclInfo array is sorted by obj_sig. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool found = false;
+
+ while (new_objnum < new_ntups)
+ {
+ int ret;
+
+ ret = strcmp(PQgetvalue(new_res, new_objnum, i_obj_sig),
+ aclinfo->obj_sig);
+ /*
+ * The new cluster doesn't have an object with same signature,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ break;
+ /*
+ * The new cluster has an object with same signatre, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ found = true;
+ new_objnum++;
+ break;
+ }
+
+ new_objnum++;
+ }
+
+ if (!found)
+ {
+ found_incompatible = true;
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n",
+ output_path, strerror(errno));
+ if (!db_used)
+ {
+ fprintf(script, "In database: %s\n", dbinfo->db_name);
+ db_used = true;
+ }
+ fprintf(script, " %s\n", aclinfo->obj_sig);
+ }
+ }
+ }
+
+ PQclear(new_res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_incompatible)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. A list of the problem objects is in the file:\n"
+ " %s\n\n", output_path);
+ }
+ else
+ check_ok();
+}
+
void
report_clusters_compatible(void)
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index d67d3a4894..2d23d83914 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -328,6 +328,80 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Gets AclInfo array of system functions, procedures and columns information
+ * which have non-default ACL.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by obj_sig.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos;
+ int ntups;
+ int aclnum;
+ int i_obj_sig = 0;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get relations, languages, functions and procedures.
+ */
+ "SELECT pg_catalog.pg_describe_object(shd.classid, shd.objid, 0) "
+ "FROM pg_catalog.pg_shdepend shd "
+ "INNER JOIN pg_catalog.pg_depend d ON d.refclassid = shd.classid AND "
+ " d.refobjid = shd.objid AND "
+ /* get only system objects */
+ " d.deptype = 'p' "
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d AND shd.objsubid = 0 AND "
+ " shd.classid IN "
+ " ('pg_proc'::regclass, 'pg_class'::regclass, 'pg_language'::regclass) "
+ "UNION ALL "
+ /*
+ * ...and union it with columns. We need to make an attribute
+ * description manually because Pre-PG 11 had different description
+ * for attributes.
+ */
+ "SELECT 'column ' || att.attname || ' of ' || "
+ " pg_catalog.pg_describe_object(shd.classid, shd.objid, 0) "
+ "FROM pg_catalog.pg_shdepend shd "
+ "INNER JOIN pg_catalog.pg_depend d ON d.refclassid = shd.classid AND "
+ " d.refobjid = shd.objid AND "
+ /* get only system objects */
+ " d.deptype = 'p' "
+ "INNER JOIN pg_catalog.pg_attribute att ON att.attrelid = shd.objid AND "
+ " att.attnum = shd.objsubid "
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d AND "
+ " shd.classid = 'pg_class'::regclass AND shd.objsubid > 0 "
+ "ORDER BY 1;", dbinfo->db_oid, dbinfo->db_oid);
+ ntups = PQntuples(res);
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * ntups);
+
+ for (aclnum = 0; aclnum < ntups; aclnum++)
+ {
+ AclInfo *curr = &aclinfos[aclnum];
+
+ curr->obj_sig = pg_strdup(PQgetvalue(res, aclnum, i_obj_sig));
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = ntups;
+ }
+}
+
+
/*
* get_db_infos()
*
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 5154a7160d..c1a41939fe 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -117,6 +117,7 @@ main(int argc, char **argv)
start_postmaster(&new_cluster, true);
check_new_cluster();
+ check_changed_signatures();
report_clusters_compatible();
pg_log(PG_REPORT,
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 729f86aa32..531d5c915b 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -149,6 +149,21 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Structure to store objects information to check if it changed its signature.
+ */
+typedef struct
+{
+ char *obj_sig; /* objects signature returned by
+ * pg_describe_object() */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -185,6 +200,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -333,6 +350,7 @@ extern OSInfo os_info;
void output_check_banner(bool live_check);
void check_and_dump_old_cluster(bool live_check);
void check_new_cluster(void);
+void check_changed_signatures(void);
void report_clusters_compatible(void);
void issue_warnings_and_set_wal_level(void);
void output_completion_banner(char *analyze_script_file_name,
@@ -392,6 +410,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
Hello!
On 11/29/19 11:07 AM, Artur Zakirov wrote:
If Anastasia doesn't mind I'd like to send new version of the patch.
On 2019/11/28 12:29, Artur Zakirov wrote:
On 2019/11/27 13:22, Michael Paquier wrote:
Yeah, the actual take is if we want to make the frontend code more
complicated with a large set of SQL queries to check that each object
ACL is modified, which adds an additional maintenance cost in
pg_upgrade.� Or if we want to keep the frontend simple and have more
backend facility to ease cross-catalog lookups for ACLs. Perhaps we
could also live with just checking after the ACLs of functions in the
short term and perhaps it covers most of the cases users would care
about..� That's tricky to conclude about and I am not sure which path
is better in the long-term, but at least it's worth discussing all
possible candidates IMO so as we make sure to not miss anything.I checked what objects changed their signatures between master and
9.6. I just ran pg_describe_object() for grantable object types,
saved the output into a file and diffed the outputs. It seems that
only functions and table columns changed their signatures. A list of
functions is big and here the list of columns:table pg_attrdef column adsrc
table pg_class column relhasoids
table pg_class column relhaspkey
table pg_constraint column consrc
table pg_proc column proisagg
table pg_proc column proiswindow
table pg_proc column protransformAs a result I think in pg_upgrade we could just check functions and
columns signatures. It might simplify the patch. And if something
changes in a future we could fix pg_upgrade too.New version of the patch differs from the previous:
- it doesn't generate script to revoke conflicting permissions (but
the patch can be fixed easily)
- generates file incompatible_objects_for_acl.txt to report which
objects changed their signatures
- uses pg_shdepend and pg_depend catalogs to get objects with custom
privileges
- uses pg_describe_object() to find objects with different signaturesCurrently relations, attributes, languages, functions and procedures
are scanned. According to the documentation foreign databases,
foreign-data wrappers, foreign servers, schemas and tablespaces also
support ACLs. But some of them doesn't have entries initialized during
initdb, others like schemas and tablespaces didn't change their names.
So the patch doesn't scan such objects.Grigory it would be great if you'll try the patch. I tested it but I
could miss something.
I`ve tested the patch on upgrade from 9.5 to master and it works now,
thank you.
But I think that 'incompatible_objects_for_acl.txt' is not a very
informative way of reporting to user the source of the problem.
There is no mentions of rolenames that holds permissions, that prevents
the upgrade, and even if they were, it is still up to user to conjure an
script to revoke all those grants, which is not a very user-friendly.
I think it should generate 'catalog_procedures.sql' script as in
previous version with all REVOKE statements, that are required to
execute for pg_upgrade to work.
--
Grigory Smolkin
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
On 2019/12/01 23:58, Grigory Smolkin wrote:
On 11/29/19 11:07 AM, Artur Zakirov wrote:
New version of the patch differs from the previous:
- it doesn't generate script to revoke conflicting permissions (but
the patch can be fixed easily)
- generates file incompatible_objects_for_acl.txt to report which
objects changed their signatures
- uses pg_shdepend and pg_depend catalogs to get objects with custom
privileges
- uses pg_describe_object() to find objects with different signaturesCurrently relations, attributes, languages, functions and procedures
are scanned. According to the documentation foreign databases,
foreign-data wrappers, foreign servers, schemas and tablespaces also
support ACLs. But some of them doesn't have entries initialized during
initdb, others like schemas and tablespaces didn't change their names.
So the patch doesn't scan such objects.Grigory it would be great if you'll try the patch. I tested it but I
could miss something.I`ve tested the patch on upgrade from 9.5 to master and it works now,
thank you.
Great!
But I think that 'incompatible_objects_for_acl.txt' is not a very
informative way of reporting to user the source of the problem.
There is no mentions of rolenames that holds permissions, that prevents
the upgrade, and even if they were, it is still up to user to conjure an
script to revoke all those grants, which is not a very user-friendly.
I tried to find some pattern how pg_upgrade decides to log list of
problem objects or to generate SQL script file to execute by user.
Nowadays only "Checking for large objects" and "Checking for hash
indexes" generate SQL script files and log WARNING message.
I think it should generate 'catalog_procedures.sql' script as in
previous version with all REVOKE statements, that are required to
execute for pg_upgrade to work.
I updated the patch. It generates "revoke_objects.sql" (similar to v3
patch) now and doesn't rely on --check option. It also logs still FATAL
message because it seems pg_upgrade should stop here since it fails
later if there are objects with changed identities.
The patch doesn't generate "incompatible_objects_for_acl.txt" now
because it would duplicate "revoke_objects.sql".
It now uses pg_identify_object() instead of pg_describe_object(), it is
easier to get column names with it.
--
Arthur
Attachments:
pg_upgrade_ACL_check_v5.patchtext/plain; charset=UTF-8; name=pg_upgrade_ACL_check_v5.patchDownload
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index cdd8788b9e..20a3f26289 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -142,6 +143,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -161,6 +164,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -443,6 +447,196 @@ check_databases_are_compatible(void)
}
}
+/*
+ * Find the location of the last dot, return NULL if not found.
+ */
+static char *
+last_dot_location(const char *identity)
+{
+ const char *p,
+ *ret = NULL;
+
+ for (p = identity; *p; p++)
+ if (*p == '.')
+ ret = p;
+ return unconstify(char *, ret);
+}
+
+/*
+ * check_for_changed_signatures()
+ *
+ * Checks that the old cluster doesn't have non-default ACL's for system objects
+ * which had different signatures in the new cluster. Otherwise generates
+ * revoke_objects.sql.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ prep_status("Checking for system objects to grant or revoke privileges");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+ /*
+ * The old cluster doesn't have system objects with non-default ACL so
+ * quickly exit.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "revoke_objects.sql");
+
+ conn = connectToServer(&new_cluster, "template1");
+ res = executeQueryOrDie(conn,
+ /* Get relations, languages, functions and procedures */
+ "SELECT obj.type, obj.identity "
+ "FROM pg_catalog.pg_depend d, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " d.refclassid, d.refobjid, d.refobjsubid) obj "
+ "WHERE deptype = 'p' AND refclassid IN ('pg_proc'::regclass, "
+ " 'pg_class'::regclass, 'pg_language'::regclass) "
+ "UNION ALL "
+ /* ...and union it with columns */
+ "SELECT obj.type, obj.identity "
+ "FROM pg_catalog.pg_depend d "
+ "INNER JOIN pg_catalog.pg_attribute att ON att.attrelid = d.refobjid, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " d.refclassid, att.attrelid, att.attnum) obj "
+ "WHERE d.deptype = 'p' AND d.refclassid = 'pg_class'::regclass "
+ "ORDER BY 2;");
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ * For every database check system objects with non-default ACL.
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool found = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(PQgetvalue(res, objnum, i_obj_ident),
+ aclinfo->obj_ident);
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ break;
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ found = true;
+ objnum++;
+ break;
+ }
+
+ objnum++;
+ }
+
+ if (!found)
+ {
+ found_changed = true;
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n",
+ output_path, strerror(errno));
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+ if (strstr(aclinfo->obj_type, "column") == NULL)
+ fprintf(script, "REVOKE ALL ON %s %s FROM %s;\n",
+ aclinfo->obj_type,
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ else
+ {
+ char *pdot = last_dot_location(aclinfo->obj_ident);
+ PQExpBufferData ident_buf;
+
+ if (pdot == NULL || *(pdot + 1) == '\0')
+ pg_fatal("invalid column identity \"%s\"",
+ aclinfo->obj_ident);
+
+ initPQExpBuffer(&ident_buf);
+ appendBinaryPQExpBuffer(&ident_buf, aclinfo->obj_ident,
+ pdot - aclinfo->obj_ident);
+
+ fprintf(script, "REVOKE ALL (%s) ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ pdot + 1, ident_buf.data,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ termPQExpBuffer(&ident_buf);
+ }
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* create_script_for_cluster_analyze()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index d67d3a4894..ebac412f55 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,96 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Gets AclInfo array of system functions, procedures and columns information
+ * which have non-default ACL.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos;
+ AclInfo *curr;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_rolname;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get relations, attributes, languages, functions and procedures.
+ */
+ "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj "
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid IN ('pg_proc'::regclass, 'pg_class'::regclass, "
+ " 'pg_language'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ */
+ "ORDER BY 2;", dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_rolname = PQfnumber(res, "rolename");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBufferData roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+
+ initPQExpBuffer(&roles_buf);
+ /* Group all role names by objects type and identity */
+ while (aclnum < PQntuples(res) &&
+ strcmp(curr->obj_ident, PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf.len != 0)
+ appendPQExpBufferChar(&roles_buf, ',');
+
+ appendPQExpBufferStr(&roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+ curr->role_names = roles_buf.data;
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -595,6 +687,7 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +713,21 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+ pg_free(acl_arr->aclinfos);
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 729f86aa32..bfc6e20de6 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -149,6 +149,23 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Structure to store objects information to check if it changed its signature.
+ */
+typedef struct
+{
+ char *obj_type; /* type name */
+ char *obj_ident; /* complete object identity */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -185,6 +202,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -392,6 +411,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
On Wed, Dec 04, 2019 at 12:17:25PM +0900, Arthur Zakirov wrote:
I updated the patch. It generates "revoke_objects.sql" (similar to v3 patch)
now and doesn't rely on --check option. It also logs still FATAL message
because it seems pg_upgrade should stop here since it fails later if there
are objects with changed identities.
(I haven't looked at the patch yet, sorry!)
FWIW, I am not much a fan of that part because the output generated by
the description is most likely not compatible with the grammar
supported.
In order to make the review easier, and to test for all the patterns
we need to cover, I have an evil idea though. Could you write a
dummy, still simple patch for HEAD which introduces
backward-incompatible changes for all the object types we want to
stress? Then by having ACLs on the source server which are fakely
broken on the target server we can make sure that the queries we have
are right, and that they report the objects we are looking for.
--
Michael
On 2019/12/04 17:15, Michael Paquier wrote:
On Wed, Dec 04, 2019 at 12:17:25PM +0900, Arthur Zakirov wrote:
I updated the patch. It generates "revoke_objects.sql" (similar to v3 patch)
now and doesn't rely on --check option. It also logs still FATAL message
because it seems pg_upgrade should stop here since it fails later if there
are objects with changed identities.(I haven't looked at the patch yet, sorry!)
FWIW, I am not much a fan of that part because the output generated by
the description is most likely not compatible with the grammar
supported.
Ah, I thought that pg_identify_object() gives properly quoted identity,
and it could be used to make SQL script.
In order to make the review easier, and to test for all the patterns
we need to cover, I have an evil idea though. Could you write a
dummy, still simple patch for HEAD which introduces
backward-incompatible changes for all the object types we want to
stress? Then by having ACLs on the source server which are fakely
broken on the target server we can make sure that the queries we have
are right, and that they report the objects we are looking for.
Sure! But I'm not sure that I understood the idea. Do you mean the patch
which adds a TAP test? It can initialize two clusters, in first it
renames some system objects and changes their ACLs. And finally the test
runs pg_upgrade which will fail.
--
Arthur
On Wed, Dec 04, 2019 at 06:15:52PM +0900, Arthur Zakirov wrote:
On 2019/12/04 17:15, Michael Paquier wrote:
FWIW, I am not much a fan of that part because the output generated by
the description is most likely not compatible with the grammar
supported.Ah, I thought that pg_identify_object() gives properly quoted identity, and
it could be used to make SQL script.
It depends on the object type. For columns I can see in your patch
that you are using a dedicated code path, but I don't think that we
should assume that there is an exact one-one mapping between the
object type and the grammar of GRANT/REVOKE for the object type
supported because both are completely independent things and
facilities. Take for example foreign data wrappers. Of course for
this patch this depends if we have system object of the type which
would be impacted. That's not the case of foreign data wrappers and
likely it will never be, but there is no way to be sure that this
won't get broken silently in the future.
Sure! But I'm not sure that I understood the idea. Do you mean the patch
which adds a TAP test? It can initialize two clusters, in first it renames
some system objects and changes their ACLs. And finally the test runs
pg_upgrade which will fail.
A TAP test won't help here because the idea is to create a patch for
HEAD which willingly introduces changes for system objects, where the
source binaries have ACLs on object types which are broken on the
target binaries with the custom patch. That's to make sure that all
the logic which would get added to pu_upgrade is working correctly.
Other ideas are welcome.
--
Michael
Hello,
On 2019/12/05 11:31, Michael Paquier wrote:
On Wed, Dec 04, 2019 at 06:15:52PM +0900, Arthur Zakirov wrote:
Ah, I thought that pg_identify_object() gives properly quoted identity, and
it could be used to make SQL script.It depends on the object type. For columns I can see in your patch
that you are using a dedicated code path, but I don't think that we
should assume that there is an exact one-one mapping between the
object type and the grammar of GRANT/REVOKE for the object type
supported because both are completely independent things and
facilities. Take for example foreign data wrappers. Of course for
this patch this depends if we have system object of the type which
would be impacted. That's not the case of foreign data wrappers and
likely it will never be, but there is no way to be sure that this
won't get broken silently in the future.
I attached new version of the patch. It still uses pg_identify_object(),
I'm not sure about other ways to build identities yet.
It handles relations, their columns, functions, procedure and languages.
There are other GRANT'able objects, like databases, foreign data
wrappers and servers, schemas and tablespaces.
I didn't include handling of databases, schemas and tablespaces because
I don't know yet how to identify if a such object is system object other
than just hard code them. They are not pinned and are not created within
pg_catalog schema.
Foreign data wrappers and servers are not handled too. There are no such
built-in objects, so it is not possible to test them with
"test_rename_catalog_objects.patch". And I'm not sure if they will be
pinned (to test if it is system) if there will be such objects in the
future.
Sure! But I'm not sure that I understood the idea. Do you mean the patch
which adds a TAP test? It can initialize two clusters, in first it renames
some system objects and changes their ACLs. And finally the test runs
pg_upgrade which will fail.A TAP test won't help here because the idea is to create a patch for
HEAD which willingly introduces changes for system objects, where the
source binaries have ACLs on object types which are broken on the
target binaries with the custom patch. That's to make sure that all
the logic which would get added to pu_upgrade is working correctly.
Other ideas are welcome.
I added "test_rename_catalog_objects.patch" and
"test_add_acl_to_catalog_objects.sql". So testing steps are following:
- initialize new source instance (e.g. pg v12) and run
"test_add_acl_to_catalog_objects.sql" on it
- apply "pg_upgrade_ACL_check_v6.patch" and
"test_add_acl_to_catalog_objects.sql" for HEAD
- initialize new target instance for HEAD
- run pg_upgrade, it should create revoke_objects.sql file
"test_rename_catalog_objects.patch" should be applied after
"pg_upgrade_ACL_check_v6.patch".
Renamed objects are the following:
- table pg_subscription -> pg_sub
- columns pg_subscription.subenabled -> subactive,
pg_subscription.subconninfo -> subconn
- view pg_stat_subscription -> pg_stat_sub
- columns pg_stat_subscription.received_lsn -> received_location,
pg_stat_subscription.latest_end_lsn -> latest_end_location
- function pg_stat_get_subscription -> pg_stat_get_sub
- language sql -> pgsql
--
Arthur
Attachments:
pg_upgrade_ACL_check_v6.patchtext/plain; charset=UTF-8; name=pg_upgrade_ACL_check_v6.patchDownload
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index cdd8788b9e..3a2004c23b 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -142,6 +143,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -161,6 +164,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -443,6 +447,223 @@ check_databases_are_compatible(void)
}
}
+/*
+ * Find the location of the last dot, return NULL if not found.
+ */
+static char *
+last_dot_location(const char *identity)
+{
+ const char *p,
+ *ret = NULL;
+
+ for (p = identity; *p; p++)
+ if (*p == '.')
+ ret = p;
+ return unconstify(char *, ret);
+}
+
+/*
+ * check_for_changed_signatures()
+ *
+ * Checks that the old cluster doesn't have non-default ACL's for system objects
+ * which had different signatures in the new cluster. Otherwise generates
+ * revoke_objects.sql.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ char subquery[QUERY_ALLOC];
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ prep_status("Checking for system objects to grant or revoke privileges");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+ /*
+ * The old cluster doesn't have system objects with non-default ACL so
+ * quickly exit.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "revoke_objects.sql");
+
+ snprintf(subquery, sizeof(subquery),
+ /* Get system relations which created in pg_catalog */
+ "SELECT 'pg_class'::regclass classid, oid objid, 0 objsubid "
+ "FROM pg_catalog.pg_class "
+ "WHERE relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system relations attributes which created in pg_catalog */
+ "SELECT 'pg_class'::regclass, att.attrelid, att.attnum "
+ "FROM pg_catalog.pg_class rel "
+ "INNER JOIN pg_catalog.pg_attribute att ON att.attrelid = att.attrelid "
+ "WHERE rel.relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system functions and procedure which created in pg_catalog */
+ "SELECT 'pg_proc'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_proc "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /*
+ * Get system languages using pg_depend, since they are schema agnostic.
+ */
+ "SELECT refclassid, refobjid, refobjsubid "
+ "FROM pg_catalog.pg_depend "
+ "WHERE deptype = 'p' AND refclassid = 'pg_language'::regclass");
+
+ conn = connectToServer(&new_cluster, "template1");
+ res = executeQueryOrDie(conn,
+ "SELECT ident.type, ident.identity "
+ "FROM (%s) obj, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " obj.classid, obj.objid, obj.objsubid) ident "
+ "ORDER BY 2;", subquery);
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ * For every database check system objects with non-default ACL.
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool found = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(PQgetvalue(res, objnum, i_obj_ident),
+ aclinfo->obj_ident);
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ break;
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ found = true;
+ objnum++;
+ break;
+ }
+
+ objnum++;
+ }
+
+ if (!found)
+ {
+ found_changed = true;
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n",
+ output_path, strerror(errno));
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+ /* Handle columns separately */
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ {
+ char *pdot = last_dot_location(aclinfo->obj_ident);
+ PQExpBufferData ident_buf;
+
+ if (pdot == NULL || *(pdot + 1) == '\0')
+ pg_fatal("invalid column identity \"%s\"",
+ aclinfo->obj_ident);
+
+ initPQExpBuffer(&ident_buf);
+ appendBinaryPQExpBuffer(&ident_buf, aclinfo->obj_ident,
+ pdot - aclinfo->obj_ident);
+
+ fprintf(script, "REVOKE ALL (%s) ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ pdot + 1, ident_buf.data,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ termPQExpBuffer(&ident_buf);
+ }
+ /*
+ * For relations except sequences we don't need to specify
+ * the object type.
+ */
+ else if (aclinfo->is_relation &&
+ strcmp(aclinfo->obj_type, "sequence") != 0)
+ fprintf(script, "REVOKE ALL ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ /* Other object types */
+ else
+ fprintf(script, "REVOKE ALL ON %s %s FROM %s;\n",
+ aclinfo->obj_type,
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* create_script_for_cluster_analyze()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index d67d3a4894..adb77178c7 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,119 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Gets AclInfo array of system functions, procedures and columns information
+ * which have non-default ACL.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos;
+ AclInfo *curr;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_rolname,
+ i_is_relation;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get relations, attributes, functions and procedures. Some system
+ * objects like views are not pinned, but these type of objects are
+ * created in pg_catalog schema.
+ */
+ "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, "
+ " CASE WHEN shd.classid = 'pg_class'::regclass THEN true "
+ " ELSE false "
+ " END is_relation "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj "
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid IN ('pg_proc'::regclass, 'pg_class'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ "UNION ALL "
+ /*
+ * Get system languages, they are pinned and we can use pg_depend
+ * here.
+ */
+ "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, false "
+ "FROM pg_catalog.pg_shdepend shd "
+ "INNER JOIN pg_catalog.pg_depend d ON d.refclassid = shd.classid "
+ " AND d.refobjid = shd.objid AND d.refobjsubid = shd.objsubid "
+ /* get only pinned system objects */
+ " AND d.deptype = 'p', "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj "
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid = 'pg_language'::regclass "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ */
+ "ORDER BY 2;", dbinfo->db_oid, dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_rolname = PQfnumber(res, "rolename");
+ i_is_relation = PQfnumber(res, "is_relation");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBufferData roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+ curr->is_relation = PQgetvalue(res, aclnum, i_is_relation)[0] == 't';
+
+ initPQExpBuffer(&roles_buf);
+ /* Group all role names by objects type and identity */
+ while (aclnum < PQntuples(res) &&
+ strcmp(curr->obj_ident, PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf.len != 0)
+ appendPQExpBufferChar(&roles_buf, ',');
+
+ appendPQExpBufferStr(&roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+
+ curr->role_names = roles_buf.data;
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -595,6 +710,7 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +736,21 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+ pg_free(acl_arr->aclinfos);
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 729f86aa32..44058720c2 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -149,6 +149,24 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Structure to store objects information to check if it changed its signature.
+ */
+typedef struct
+{
+ char *obj_type; /* type name */
+ char *obj_ident; /* complete object identity */
+ bool is_relation; /* is the object relation */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -185,6 +203,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -392,6 +412,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
test_rename_catalog_objects.patchtext/plain; charset=UTF-8; name=test_rename_catalog_objects.patchDownload
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index a51153236a..460c6afa66 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -68,7 +68,7 @@ CATALOG_HEADERS := \
pg_foreign_table.h pg_policy.h pg_replication_origin.h \
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
- pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
+ pg_sequence.h pg_publication.h pg_publication_rel.h pg_sub.h \
pg_subscription_rel.h
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index ea5666ebb8..75d5773672 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -50,7 +50,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 6b104695c0..3022b2b029 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -38,7 +38,7 @@
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/toasting.h"
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index d07bb4496e..2eab802176 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 5d64791c5d..46f2466aed 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -42,7 +42,7 @@ SET search_path TO information_schema;
/* Expand any 1-D array into a set with integers 1..N */
CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
RETURNS SETOF RECORD
- LANGUAGE sql STRICT IMMUTABLE PARALLEL SAFE
+ LANGUAGE pgsql STRICT IMMUTABLE PARALLEL SAFE
AS 'select $1[s], s - pg_catalog.array_lower($1,1) + 1
from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
pg_catalog.array_upper($1,1),
@@ -51,7 +51,7 @@ CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
/* Given an index's OID and an underlying-table column number, return the
* column's position in the index (NULL if not there) */
CREATE FUNCTION _pg_index_position(oid, smallint) RETURNS int
- LANGUAGE sql STRICT STABLE
+ LANGUAGE pgsql STRICT STABLE
AS $$
SELECT (ss.a).n FROM
(SELECT information_schema._pg_expandarray(indkey) AS a
@@ -60,7 +60,7 @@ SELECT (ss.a).n FROM
$$;
CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -68,7 +68,7 @@ CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
$$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typbasetype ELSE $1.atttypid END$$;
CREATE FUNCTION _pg_truetypmod(pg_attribute, pg_type) RETURNS int4
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -78,7 +78,7 @@ $$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typtypmod ELSE $1.atttypmod END$$;
-- these functions encapsulate knowledge about the encoding of typmod:
CREATE FUNCTION _pg_char_max_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -94,7 +94,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_char_octet_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -110,7 +110,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -131,7 +131,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision_radix(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -143,7 +143,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_scale(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -159,7 +159,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_datetime_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -175,7 +175,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_interval_type(typid oid, mod int4) RETURNS text
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -1477,7 +1477,7 @@ CREATE VIEW routines AS
CAST(null AS cardinal_number) AS maximum_cardinality,
CAST(CASE WHEN p.prokind <> 'p' THEN 0 END AS sql_identifier) AS dtd_identifier,
- CAST(CASE WHEN l.lanname = 'sql' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
+ CAST(CASE WHEN l.lanname = 'pgsql' THEN 'PGSQL' ELSE 'EXTERNAL' END AS character_data)
AS routine_body,
CAST(
CASE WHEN pg_has_role(p.proowner, 'USAGE') THEN p.prosrc ELSE null END
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index ae3002bb42..39c803fa00 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -52,7 +52,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
@@ -505,10 +505,10 @@ static const ObjectPropertyType ObjectProperty[] =
SubscriptionObjectIndexId,
SUBSCRIPTIONOID,
SUBSCRIPTIONNAME,
- Anum_pg_subscription_oid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_oid,
+ Anum_pg_sub_subname,
InvalidAttrNumber,
- Anum_pg_subscription_subowner,
+ Anum_pg_sub_subowner,
InvalidAttrNumber,
OBJECT_SUBSCRIPTION,
true
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 59f97bf3d0..900acb90a3 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -40,7 +40,7 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index 68d88ff499..c93e7037fc 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -20,7 +20,7 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/indexing.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
@@ -64,12 +64,12 @@ GetSubscription(Oid subid, bool missing_ok)
sub->dbid = subform->subdbid;
sub->name = pstrdup(NameStr(subform->subname));
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subconninfo,
+ Anum_pg_sub_subconn,
&isnull);
Assert(!isnull);
sub->conninfo = TextDatumGetCString(datum);
@@ -77,7 +77,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subslotname,
+ Anum_pg_sub_subslotname,
&isnull);
if (!isnull)
sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));
@@ -87,7 +87,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get synccommit */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subsynccommit,
+ Anum_pg_sub_subsynccommit,
&isnull);
Assert(!isnull);
sub->synccommit = TextDatumGetCString(datum);
@@ -95,7 +95,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get publications */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subpublications,
+ Anum_pg_sub_subpublications,
&isnull);
Assert(!isnull);
sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
@@ -121,7 +121,7 @@ CountDBSubscriptions(Oid dbid)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- Anum_pg_subscription_subdbid,
+ Anum_pg_sub_subdbid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
@@ -163,7 +163,7 @@ get_subscription_oid(const char *subname, bool missing_ok)
{
Oid oid;
- oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(subname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index f7800f01a6..20597dd1ff 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -477,7 +477,7 @@ SELECT
l.provider, l.label
FROM
pg_shseclabel l
- JOIN pg_subscription s ON l.classoid = s.tableoid AND l.objoid = s.oid
+ JOIN pg_sub s ON l.classoid = s.tableoid AND l.objoid = s.oid
UNION ALL
SELECT
l.objoid, l.classoid, 0::int4 AS objsubid,
@@ -803,19 +803,19 @@ CREATE VIEW pg_stat_wal_receiver AS
FROM pg_stat_get_wal_receiver() s
WHERE s.pid IS NOT NULL;
-CREATE VIEW pg_stat_subscription AS
+CREATE VIEW pg_stat_sub AS
SELECT
su.oid AS subid,
su.subname,
st.pid,
st.relid,
- st.received_lsn,
+ st.received_lsn received_location,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_lsn latest_end_location,
st.latest_end_time
- FROM pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL) st
+ FROM pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL) st
ON (st.subid = su.oid);
CREATE VIEW pg_stat_ssl AS
@@ -1062,9 +1062,9 @@ CREATE VIEW pg_replication_origin_status AS
REVOKE ALL ON pg_replication_origin_status FROM public;
-- All columns of pg_subscription except subconninfo are readable.
-REVOKE ALL ON pg_subscription FROM public;
-GRANT SELECT (subdbid, subname, subowner, subenabled, subslotname, subpublications)
- ON pg_subscription TO public;
+REVOKE ALL ON pg_sub FROM public;
+GRANT SELECT (subdbid, subname, subowner, subactive, subslotname, subpublications)
+ ON pg_sub TO public;
--
@@ -1114,7 +1114,7 @@ FROM pg_catalog.ts_parse(
) AS tt
WHERE tt.tokid = parse.tokid
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(regconfig,text) IS
'debug function for text search configuration';
@@ -1130,7 +1130,7 @@ RETURNS SETOF record AS
$$
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1);
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(text) IS
'debug function for current text search configuration';
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index d425ef935e..9429356e81 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -35,7 +35,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index a70e75a219..2b3bf4c888 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -38,7 +38,7 @@
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 5408edcfc2..911265ff6f 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -23,7 +23,7 @@
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
@@ -309,8 +309,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
Relation rel;
ObjectAddress myself;
Oid subid;
- bool nulls[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
Oid owner = GetUserId();
HeapTuple tup;
bool connect;
@@ -361,7 +361,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Check if name is used */
- subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(stmt->subname));
if (OidIsValid(subid))
{
@@ -392,23 +392,23 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
memset(nulls, false, sizeof(nulls));
subid = GetNewOidWithIndex(rel, SubscriptionObjectIndexId,
- Anum_pg_subscription_oid);
- values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
- values[Anum_pg_subscription_subname - 1] =
+ Anum_pg_sub_oid);
+ values[Anum_pg_sub_oid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
+ values[Anum_pg_sub_subname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
- values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
- values[Anum_pg_subscription_subenabled - 1] = BoolGetDatum(enabled);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subowner - 1] = ObjectIdGetDatum(owner);
+ values[Anum_pg_sub_subactive - 1] = BoolGetDatum(enabled);
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(conninfo);
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- values[Anum_pg_subscription_subsynccommit - 1] =
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(publications);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -623,9 +623,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
{
Relation rel;
ObjectAddress myself;
- bool nulls[Natts_pg_subscription];
- bool replaces[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ bool replaces[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
HeapTuple tup;
Oid subid;
bool update_tuple = false;
@@ -683,18 +683,18 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
"slot_name = NONE")));
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- replaces[Anum_pg_subscription_subslotname - 1] = true;
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ replaces[Anum_pg_sub_subslotname - 1] = true;
}
if (synchronous_commit)
{
- values[Anum_pg_subscription_subsynccommit - 1] =
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- replaces[Anum_pg_subscription_subsynccommit - 1] = true;
+ replaces[Anum_pg_sub_subsynccommit - 1] = true;
}
update_tuple = true;
@@ -716,9 +716,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot enable subscription that does not have a slot name")));
- values[Anum_pg_subscription_subenabled - 1] =
+ values[Anum_pg_sub_subactive - 1] =
BoolGetDatum(enabled);
- replaces[Anum_pg_subscription_subenabled - 1] = true;
+ replaces[Anum_pg_sub_subactive - 1] = true;
if (enabled)
ApplyLauncherWakeupAtCommit();
@@ -733,9 +733,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
/* Check the connection info string. */
walrcv_check_conninfo(stmt->conninfo);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(stmt->conninfo);
- replaces[Anum_pg_subscription_subconninfo - 1] = true;
+ replaces[Anum_pg_sub_subconn - 1] = true;
update_tuple = true;
break;
@@ -748,9 +748,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
NULL, NULL, NULL, ©_data,
NULL, &refresh);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(stmt->publication);
- replaces[Anum_pg_subscription_subpublications - 1] = true;
+ replaces[Anum_pg_sub_subpublications - 1] = true;
update_tuple = true;
@@ -884,19 +884,19 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
/* Get subname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subname, &isnull);
+ Anum_pg_sub_subname, &isnull);
Assert(!isnull);
subname = pstrdup(NameStr(*DatumGetName(datum)));
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subconninfo, &isnull);
+ Anum_pg_sub_subconn, &isnull);
Assert(!isnull);
conninfo = TextDatumGetCString(datum);
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subslotname, &isnull);
+ Anum_pg_sub_subslotname, &isnull);
if (!isnull)
slotname = pstrdup(NameStr(*DatumGetName(datum)));
else
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 4643af95fe..23b8df943b 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -22,7 +22,7 @@
#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "funcapi.h"
#include "libpq/pqsignal.h"
@@ -97,7 +97,7 @@ static volatile sig_atomic_t got_SIGHUP = false;
static bool on_commit_launcher_wakeup = false;
-Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
+Datum pg_stat_get_sub(PG_FUNCTION_ARGS);
/*
@@ -149,7 +149,7 @@ get_subscription_list(void)
sub->oid = subform->oid;
sub->dbid = subform->subdbid;
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->name = pstrdup(NameStr(subform->subname));
/* We don't fill fields we are not interested in. */
@@ -1084,7 +1084,7 @@ IsLogicalLauncher(void)
* Returns state of the subscriptions.
*/
Datum
-pg_stat_get_subscription(PG_FUNCTION_ARGS)
+pg_stat_get_sub(PG_FUNCTION_ARGS)
{
#define PG_STAT_GET_SUBSCRIPTION_COLS 8
Oid subid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index ced0d191c2..67cab841dd 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -29,7 +29,7 @@
#include "access/xlog_internal.h"
#include "catalog/catalog.h"
#include "catalog/namespace.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "commands/tablecmds.h"
#include "commands/trigger.h"
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 50f8912c13..9330d78c8a 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -59,7 +59,7 @@
#include "catalog/pg_rewrite.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
@@ -117,7 +117,7 @@ static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_
static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
-static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_subscription] = {Schema_pg_subscription};
+static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_sub] = {Schema_pg_sub};
/*
* Hash tables that index the relation cache
@@ -3648,8 +3648,8 @@ RelationCacheInitializePhase2(void)
Natts_pg_auth_members, Desc_pg_auth_members);
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
Natts_pg_shseclabel, Desc_pg_shseclabel);
- formrdesc("pg_subscription", SubscriptionRelation_Rowtype_Id, true,
- Natts_pg_subscription, Desc_pg_subscription);
+ formrdesc("pg_sub", SubscriptionRelation_Rowtype_Id, true,
+ Natts_pg_sub, Desc_pg_subscription);
#define NUM_CRITICAL_SHARED_RELS 5 /* fix if you change list above */
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index d69c0ff813..d021d37fba 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -63,7 +63,7 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
@@ -776,8 +776,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionNameIndexId,
2,
{
- Anum_pg_subscription_subdbid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_subdbid,
+ Anum_pg_sub_subname,
0,
0
},
@@ -787,7 +787,7 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionObjectIndexId,
1,
{
- Anum_pg_subscription_oid,
+ Anum_pg_sub_oid,
0,
0,
0
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 08658c8e86..cca150a39c 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4117,7 +4117,7 @@ getSubscriptions(Archive *fout)
int n;
res = ExecuteSqlQuery(fout,
- "SELECT count(*) FROM pg_subscription "
+ "SELECT count(*) FROM pg_sub "
"WHERE subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
PGRES_TUPLES_OK);
@@ -4136,9 +4136,9 @@ getSubscriptions(Archive *fout)
appendPQExpBuffer(query,
"SELECT s.tableoid, s.oid, s.subname,"
"(%s s.subowner) AS rolname, "
- " s.subconninfo, s.subslotname, s.subsynccommit, "
+ " s.subconn, s.subslotname, s.subsynccommit, "
" s.subpublications "
- "FROM pg_subscription s "
+ "FROM pg_sub s "
"WHERE s.subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
username_subquery);
@@ -4150,7 +4150,7 @@ getSubscriptions(Archive *fout)
i_oid = PQfnumber(res, "oid");
i_subname = PQfnumber(res, "subname");
i_rolname = PQfnumber(res, "rolname");
- i_subconninfo = PQfnumber(res, "subconninfo");
+ i_subconninfo = PQfnumber(res, "subconn");
i_subslotname = PQfnumber(res, "subslotname");
i_subsynccommit = PQfnumber(res, "subsynccommit");
i_subpublications = PQfnumber(res, "subpublications");
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index ef4445b017..8d4c8d8eb5 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -357,10 +357,10 @@ DECLARE_UNIQUE_INDEX(pg_publication_rel_oid_index, 6112, on pg_publication_rel u
DECLARE_UNIQUE_INDEX(pg_publication_rel_prrelid_prpubid_index, 6113, on pg_publication_rel using btree(prrelid oid_ops, prpubid oid_ops));
#define PublicationRelPrrelidPrpubidIndexId 6113
-DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_sub using btree(oid oid_ops));
#define SubscriptionObjectIndexId 6114
-DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_sub using btree(subdbid oid_ops, subname name_ops));
#define SubscriptionNameIndexId 6115
DECLARE_UNIQUE_INDEX(pg_subscription_rel_srrelid_srsubid_index, 6117, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
diff --git a/src/include/catalog/pg_language.dat b/src/include/catalog/pg_language.dat
index 02dde38a1c..5c82c1b545 100644
--- a/src/include/catalog/pg_language.dat
+++ b/src/include/catalog/pg_language.dat
@@ -20,6 +20,6 @@
lanname => 'c', lanvalidator => 'fmgr_c_validator' },
{ oid => '14', oid_symbol => 'SQLlanguageId',
descr => 'SQL-language functions',
- lanname => 'sql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
+ lanname => 'pgsql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
]
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index ac8f64b219..27a80a6a5f 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2281,7 +2281,7 @@
proname => 'justify_days', prorettype => 'interval',
proargtypes => 'interval', prosrc => 'interval_justify_days' },
{ oid => '1176', descr => 'convert date and time to timestamp with time zone',
- proname => 'timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'date time',
prosrc => 'select cast(($1 + $2) as timestamp with time zone)' },
{ oid => '1178', descr => 'convert timestamp with time zone to date',
@@ -2334,16 +2334,16 @@
prosrc => 'interval_scale' },
{ oid => '1215', descr => 'get description for object id and catalog name',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0' },
{ oid => '1216', descr => 'get description for table column',
- proname => 'col_description', prolang => 'sql', procost => '100',
+ proname => 'col_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'pg_catalog.pg_class\'::pg_catalog.regclass and objsubid = $2' },
{ oid => '1993',
descr => 'get description for object id and shared catalog name',
- proname => 'shobj_description', prolang => 'sql', procost => '100',
+ proname => 'shobj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP)' },
@@ -2519,13 +2519,13 @@
prosrc => 'hashtidextended' },
{ oid => '1296',
- proname => 'timedate_pl', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'timedate_pl', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'time date', prosrc => 'select ($2 + $1)' },
{ oid => '1297',
proname => 'datetimetz_pl', prorettype => 'timestamptz',
proargtypes => 'date timetz', prosrc => 'datetimetz_timestamptz' },
{ oid => '1298',
- proname => 'timetzdate_pl', prolang => 'sql', prorettype => 'timestamptz',
+ proname => 'timetzdate_pl', prolang => 'pgsql', prorettype => 'timestamptz',
proargtypes => 'timetz date', prosrc => 'select ($2 + $1)' },
{ oid => '1299', descr => 'current transaction time',
proname => 'now', provolatile => 's', prorettype => 'timestamptz',
@@ -2567,17 +2567,17 @@
proargtypes => 'timestamptz timestamptz timestamptz timestamptz',
prosrc => 'overlaps_timestamp' },
{ oid => '1305', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1306', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz timestamptz timestamptz interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1307', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz timestamptz',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2586,15 +2586,15 @@
proname => 'overlaps', proisstrict => 'f', prorettype => 'bool',
proargtypes => 'time time time time', prosrc => 'overlaps_time' },
{ oid => '1309', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1310', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time time time interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1311', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time time',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2675,7 +2675,7 @@
# This form of obj_description is now deprecated, since it will fail if
# OIDs are not unique across system catalogs. Use the other form instead.
{ oid => '1348', descr => 'deprecated, use two-argument form instead',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and objsubid = 0' },
@@ -2759,7 +2759,7 @@
prosrc => 'textlen' },
{ oid => '1384', descr => 'extract field from date',
- proname => 'date_part', prolang => 'sql', prorettype => 'float8',
+ proname => 'date_part', prolang => 'pgsql', prorettype => 'float8',
proargtypes => 'text date',
prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time zone))' },
{ oid => '1385', descr => 'extract field from time',
@@ -2767,7 +2767,7 @@
prosrc => 'time_part' },
{ oid => '1386',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp with time zone), $1)' },
@@ -2882,7 +2882,7 @@
proname => 'box_div', prorettype => 'box', proargtypes => 'box point',
prosrc => 'box_div' },
{ oid => '1426',
- proname => 'path_contain_pt', prolang => 'sql', prorettype => 'bool',
+ proname => 'path_contain_pt', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'path point', prosrc => 'select pg_catalog.on_ppath($2, $1)' },
{ oid => '1428',
proname => 'poly_contain_pt', prorettype => 'bool',
@@ -3142,7 +3142,7 @@
proname => 'center', prorettype => 'point', proargtypes => 'circle',
prosrc => 'circle_center' },
{ oid => '1544', descr => 'convert circle to 12-vertex polygon',
- proname => 'polygon', prolang => 'sql', prorettype => 'polygon',
+ proname => 'polygon', prolang => 'pgsql', prorettype => 'polygon',
proargtypes => 'circle', prosrc => 'select pg_catalog.polygon(12, $1)' },
{ oid => '1545', descr => 'number of points',
proname => 'npoints', prorettype => 'int4', proargtypes => 'path',
@@ -3438,11 +3438,11 @@
proname => 'translate', prorettype => 'text', proargtypes => 'text text text',
prosrc => 'translate' },
{ oid => '879', descr => 'left-pad string to length',
- proname => 'lpad', prolang => 'sql', prorettype => 'text',
+ proname => 'lpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.lpad($1, $2, \' \')' },
{ oid => '880', descr => 'right-pad string to length',
- proname => 'rpad', prolang => 'sql', prorettype => 'text',
+ proname => 'rpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.rpad($1, $2, \' \')' },
{ oid => '881', descr => 'trim spaces from left end of string',
@@ -4033,7 +4033,7 @@
proname => 'inetpl', prorettype => 'inet', proargtypes => 'inet int8',
prosrc => 'inetpl' },
{ oid => '2631',
- proname => 'int8pl_inet', prolang => 'sql', prorettype => 'inet',
+ proname => 'int8pl_inet', prolang => 'pgsql', prorettype => 'inet',
proargtypes => 'int8 inet', prosrc => 'select $2 + $1' },
{ oid => '2632',
proname => 'inetmi_int8', prorettype => 'inet', proargtypes => 'inet int8',
@@ -4165,13 +4165,13 @@
proname => 'round', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_round' },
{ oid => '1708', descr => 'value rounded to \'scale\' of zero',
- proname => 'round', prolang => 'sql', prorettype => 'numeric',
+ proname => 'round', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.round($1,0)' },
{ oid => '1709', descr => 'value truncated to \'scale\'',
proname => 'trunc', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_trunc' },
{ oid => '1710', descr => 'value truncated to \'scale\' of zero',
- proname => 'trunc', prolang => 'sql', prorettype => 'numeric',
+ proname => 'trunc', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.trunc($1,0)' },
{ oid => '1711', descr => 'nearest integer >= value',
proname => 'ceil', prorettype => 'numeric', proargtypes => 'numeric',
@@ -4258,10 +4258,10 @@
proname => 'numeric', prorettype => 'numeric', proargtypes => 'int4',
prosrc => 'int4_numeric' },
{ oid => '1741', descr => 'base 10 logarithm',
- proname => 'log', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1481', descr => 'base 10 logarithm',
- proname => 'log10', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log10', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1742', descr => 'convert float4 to numeric',
proname => 'numeric', prorettype => 'numeric', proargtypes => 'float4',
@@ -4394,7 +4394,7 @@
proname => 'quote_literal', prorettype => 'text', proargtypes => 'text',
prosrc => 'quote_literal' },
{ oid => '1285', descr => 'quote a data value for usage in a querystring',
- proname => 'quote_literal', prolang => 'sql', provolatile => 's',
+ proname => 'quote_literal', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_literal($1::pg_catalog.text)' },
{ oid => '1289',
@@ -4403,7 +4403,7 @@
proargtypes => 'text', prosrc => 'quote_nullable' },
{ oid => '1290',
descr => 'quote a possibly-null data value for usage in a querystring',
- proname => 'quote_nullable', prolang => 'sql', proisstrict => 'f',
+ proname => 'quote_nullable', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_nullable($1::pg_catalog.text)' },
@@ -4442,13 +4442,13 @@
prorettype => 'text', proargtypes => 'text', prosrc => 'text_format_nv' },
{ oid => '1810', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bytea', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1811', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'text', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1812', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bit', prosrc => 'select pg_catalog.length($1)' },
# Selectivity estimators for LIKE and related operators
@@ -4767,7 +4767,7 @@
prosrc => 'to_ascii_encname' },
{ oid => '1848',
- proname => 'interval_pl_time', prolang => 'sql', prorettype => 'time',
+ proname => 'interval_pl_time', prolang => 'pgsql', prorettype => 'time',
proargtypes => 'interval time', prosrc => 'select $2 + $1' },
{ oid => '1850',
@@ -5178,12 +5178,12 @@
proargnames => '{pid,status,receive_start_lsn,receive_start_tli,received_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
prosrc => 'pg_stat_get_wal_receiver' },
{ oid => '6118', descr => 'statistics: information about subscription',
- proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
+ proname => 'pg_stat_get_sub', proisstrict => 'f', provolatile => 's',
proparallel => 'r', prorettype => 'record', proargtypes => 'oid',
proallargtypes => '{oid,oid,oid,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}',
proargmodes => '{i,o,o,o,o,o,o,o,o}',
proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}',
- prosrc => 'pg_stat_get_subscription' },
+ prosrc => 'pg_stat_get_sub' },
{ oid => '2026', descr => 'statistics: current backend PID',
proname => 'pg_backend_pid', provolatile => 's', proparallel => 'r',
prorettype => 'int4', proargtypes => '', prosrc => 'pg_backend_pid' },
@@ -5579,11 +5579,11 @@
proargtypes => 'timetz int4', prosrc => 'timetz_scale' },
{ oid => '2003',
- proname => 'textanycat', prolang => 'sql', provolatile => 's',
+ proname => 'textanycat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'text anynonarray',
prosrc => 'select $1 || $2::pg_catalog.text' },
{ oid => '2004',
- proname => 'anytextcat', prolang => 'sql', provolatile => 's',
+ proname => 'anytextcat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anynonarray text',
prosrc => 'select $1::pg_catalog.text || $2' },
@@ -5683,15 +5683,15 @@
proargtypes => 'timestamp timestamp timestamp timestamp',
prosrc => 'overlaps_timestamp' },
{ oid => '2042', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '2043', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp timestamp timestamp interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '2044', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp timestamp',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
{ oid => '2045', descr => 'less-equal-greater',
@@ -5757,7 +5757,7 @@
proargtypes => 'timestamp timestamp', prosrc => 'timestamp_age' },
{ oid => '2059',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamp',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp without time zone), $1)' },
@@ -5778,7 +5778,7 @@
proname => 'substring', prorettype => 'text', proargtypes => 'text text',
prosrc => 'textregexsubstr' },
{ oid => '2074', descr => 'extract text matching SQL regular expression',
- proname => 'substring', prolang => 'sql', prorettype => 'text',
+ proname => 'substring', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text text text',
prosrc => 'select pg_catalog.substring($1, pg_catalog.similar_to_escape($2, $3))' },
@@ -6117,11 +6117,11 @@
proname => 'pg_sleep', provolatile => 'v', prorettype => 'void',
proargtypes => 'float8', prosrc => 'pg_sleep' },
{ oid => '3935', descr => 'sleep for the specified interval',
- proname => 'pg_sleep_for', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_for', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'interval',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from pg_catalog.clock_timestamp() operator(pg_catalog.+) $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '3936', descr => 'sleep until the specified time',
- proname => 'pg_sleep_until', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_until', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '315', descr => 'Is JIT compilation available in this session?',
@@ -6922,7 +6922,7 @@
proargtypes => 'name', prosrc => 'pg_database_size_name' },
{ oid => '2325',
descr => 'disk space usage for the main fork of the specified table or index',
- proname => 'pg_relation_size', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_relation_size', prolang => 'pgsql', provolatile => 'v',
prorettype => 'int8', proargtypes => 'regclass',
prosrc => 'select pg_catalog.pg_relation_size($1, \'main\')' },
{ oid => '2332',
@@ -7760,21 +7760,21 @@
# formerly-missing interval + datetime operators
{ oid => '2546',
- proname => 'interval_pl_date', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'interval_pl_date', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'interval date', prosrc => 'select $2 + $1' },
{ oid => '2547',
- proname => 'interval_pl_timetz', prolang => 'sql', prorettype => 'timetz',
+ proname => 'interval_pl_timetz', prolang => 'pgsql', prorettype => 'timetz',
proargtypes => 'interval timetz', prosrc => 'select $2 + $1' },
{ oid => '2548',
- proname => 'interval_pl_timestamp', prolang => 'sql',
+ proname => 'interval_pl_timestamp', prolang => 'pgsql',
prorettype => 'timestamp', proargtypes => 'interval timestamp',
prosrc => 'select $2 + $1' },
{ oid => '2549',
- proname => 'interval_pl_timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'interval_pl_timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'interval timestamptz',
prosrc => 'select $2 + $1' },
{ oid => '2550',
- proname => 'integer_pl_date', prolang => 'sql', prorettype => 'date',
+ proname => 'integer_pl_date', prolang => 'pgsql', prorettype => 'date',
proargtypes => 'int4 date', prosrc => 'select $2 + $1' },
{ oid => '2556', descr => 'get OIDs of databases in a tablespace',
@@ -8163,7 +8163,7 @@
proname => 'xpath', prorettype => '_xml', proargtypes => 'text xml _text',
prosrc => 'xpath' },
{ oid => '2932', descr => 'evaluate XPath expression',
- proname => 'xpath', prolang => 'sql', prorettype => '_xml',
+ proname => 'xpath', prolang => 'pgsql', prorettype => '_xml',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath($1, $2, \'{}\'::pg_catalog.text[])' },
@@ -8176,7 +8176,7 @@
proname => 'xpath_exists', prorettype => 'bool',
proargtypes => 'text xml _text', prosrc => 'xpath_exists' },
{ oid => '3050', descr => 'test XML value against XPath expression',
- proname => 'xpath_exists', prolang => 'sql', prorettype => 'bool',
+ proname => 'xpath_exists', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '3051', descr => 'determine if a string is well formed XML',
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_sub.h
similarity index 90%
rename from src/include/catalog/pg_subscription.h
rename to src/include/catalog/pg_sub.h
index 3cb13d897e..6628814833 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_sub.h
@@ -18,7 +18,7 @@
#define PG_SUBSCRIPTION_H
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_d.h"
+#include "catalog/pg_sub_d.h"
#include "nodes/pg_list.h"
@@ -36,7 +36,7 @@
*
* NOTE: When adding a column, also update system_views.sql.
*/
-CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
+CATALOG(pg_sub,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
@@ -45,12 +45,12 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
Oid subowner; /* Owner of the subscription */
- bool subenabled; /* True if the subscription is enabled (the
+ bool subactive; /* True if the subscription is enabled (the
* worker should be running) */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* Connection string to the publisher */
- text subconninfo BKI_FORCE_NOT_NULL;
+ text subconn BKI_FORCE_NOT_NULL;
/* Slot name on publisher */
NameData subslotname;
diff --git a/src/include/catalog/toasting.h b/src/include/catalog/toasting.h
index cc5dfed0bf..40a0c901cd 100644
--- a/src/include/catalog/toasting.h
+++ b/src/include/catalog/toasting.h
@@ -98,7 +98,7 @@ DECLARE_TOAST(pg_shdescription, 2846, 2847);
DECLARE_TOAST(pg_shseclabel, 4060, 4061);
#define PgShseclabelToastTable 4060
#define PgShseclabelToastIndex 4061
-DECLARE_TOAST(pg_subscription, 4183, 4184);
+DECLARE_TOAST(pg_sub, 4183, 4184);
#define PgSubscriptionToastTable 4183
#define PgSubscriptionToastIndex 4184
DECLARE_TOAST(pg_tablespace, 4185, 4186);
diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h
index 05f4936419..d1cf8906a7 100644
--- a/src/include/replication/worker_internal.h
+++ b/src/include/replication/worker_internal.h
@@ -15,7 +15,7 @@
#include <signal.h>
#include "access/xlogdefs.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
On 17.12.2019 11:10, Arthur Zakirov wrote:
On 2019/12/05 11:31, Michael Paquier wrote:
On Wed, Dec 04, 2019 at 06:15:52PM +0900, Arthur Zakirov wrote:
Ah, I thought that pg_identify_object() gives properly quoted
identity, and
it could be used to make SQL script.It depends on the object type.� For columns I can see in your patch
that you are using a dedicated code path, but I don't think that we
should assume that there is an exact one-one mapping between the
object type and the grammar of GRANT/REVOKE for the object type
supported because both are completely independent things and
facilities.� Take for example foreign data wrappers.� Of course for
this patch this depends if we have system object of the type which
would be impacted.� That's not the case of foreign data wrappers and
likely it will never be, but there is no way to be sure that this
won't get broken silently in the future.I attached new version of the patch. It still uses
pg_identify_object(), I'm not sure about other ways to build
identities yet.
Michael, do I understand it correctly that your concerns about
pg_identify_object() relate only to the revoke sql script?
Now, I tend to agree that we should split this patch into two separate
parts, to make it simpler.
The first patch is to find affected objects and print warnings and the
second is to generate script.
I added "test_rename_catalog_objects.patch" and
"test_add_acl_to_catalog_objects.sql". So testing steps are following:
- initialize new source instance (e.g. pg v12) and run
"test_add_acl_to_catalog_objects.sql" on it
- apply "pg_upgrade_ACL_check_v6.patch" and
"test_add_acl_to_catalog_objects.sql" for HEAD
- initialize new target instance for HEAD
- run pg_upgrade, it should create revoke_objects.sql file"test_rename_catalog_objects.patch" should be applied after
"pg_upgrade_ACL_check_v6.patch".Renamed objects are the following:
- table pg_subscription -> pg_sub
- columns pg_subscription.subenabled -> subactive,
pg_subscription.subconninfo -> subconn
- view pg_stat_subscription -> pg_stat_sub
- columns pg_stat_subscription.received_lsn -> received_location,
pg_stat_subscription.latest_end_lsn -> latest_end_location
- function pg_stat_get_subscription -> pg_stat_get_sub
- language sql -> pgsql
I've tried to test it. Script is attached.
Described test case works. If a new cluster contains renamed objects,
/pg_upgrade --check/ successfully finds them and generates a script to
revoke non-default ACL. Though, without
test_rename_catalog_objects.patch, /pg_upgrade --check/ still generates
the same message, which is false positive.
I am going to fix it and send the updated patch later this week.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
On 12/17/19 3:10 AM, Arthur Zakirov wrote:
I attached new version of the patch. It still uses pg_identify_object(),
I'm not sure about other ways to build identities yet.
This patch applies and builds but fails regression tests on Linux and
Windows:
https://travis-ci.org/postgresql-cfbot/postgresql/builds/666134656
https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.85292
The CF entry has been updated to Waiting on Author.
Regards,
--
-David
david@pgmasters.net
Hello David,
On 3/25/2020 2:08 AM, David Steele wrote:
On 12/17/19 3:10 AM, Arthur Zakirov wrote:
I attached new version of the patch. It still uses
pg_identify_object(), I'm not sure about other ways to build
identities yet.This patch applies and builds but fails regression tests on Linux and
Windows:
https://travis-ci.org/postgresql-cfbot/postgresql/builds/666134656
https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.85292
Regression tests fail because cfbot applies
"test_rename_catalog_objects.patch". Regression tests pass without it.
This patch shouldn't be applied by cfbot. I'm not sure how to do this.
But maybe it is possible to use different extension name for the test
patch, not ".patch".
--
Artur
On 25 Mar 2020, at 03:12, Artur Zakirov <zaartur@gmail.com> wrote:
Regression tests fail because cfbot applies "test_rename_catalog_objects.patch". Regression tests pass without it.
This patch shouldn't be applied by cfbot. I'm not sure how to do this. But maybe it is possible to use different extension name for the test patch, not ".patch".
To get around that, post a new version again without the test_ patch, that
should make the cfbot pick up only the "new" patches.
cheers ./daniel
On Wed, Mar 25, 2020 at 11:12:05AM +0900, Artur Zakirov wrote:
Hello David,
On 3/25/2020 2:08 AM, David Steele wrote:
On 12/17/19 3:10 AM, Arthur Zakirov wrote:
I attached new version of the patch. It still uses
pg_identify_object(), I'm not sure about other ways to build
identities yet.This patch applies and builds but fails regression tests on Linux and
Windows:
https://travis-ci.org/postgresql-cfbot/postgresql/builds/666134656
https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.85292Regression tests fail because cfbot applies
"test_rename_catalog_objects.patch". Regression tests pass without it.This patch shouldn't be applied by cfbot. I'm not sure how to do this. But
maybe it is possible to use different extension name for the test patch, not
".patch".
Yes, see Tom's message here:
/messages/by-id/14255.1536781029@sss.pgh.pa.us
I don't know what extensions cfbot looks for; in that case I didn't have a file
extension at all.
--
Justin
New version of the patch is attached. I fixed several issues in the
check_for_changed_signatures().
Now it passes check without "test_rename_catalog_objects" and fails
(generates script) with it. Test script pg_upgrade_ACL_test.sh
demonstrates this.
The only known issue left is the usage of pg_identify_object(), though I
don't see a problem here with object types that this patch involves.
As I updated the code, I will leave this patch in Need Review.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v7.patchtext/x-patch; charset=UTF-8; name=pg_upgrade_ACL_check_v7.patchDownload
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 00aef855dc..63a216c383 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -142,6 +143,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -161,6 +164,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -443,6 +447,229 @@ check_databases_are_compatible(void)
}
}
+/*
+ * Find the location of the last dot, return NULL if not found.
+ */
+static char *
+last_dot_location(const char *identity)
+{
+ const char *p,
+ *ret = NULL;
+
+ for (p = identity; *p; p++)
+ if (*p == '.')
+ ret = p;
+ return unconstify(char *, ret);
+}
+
+/*
+ * check_for_changed_signatures()
+ *
+ * Checks that the old cluster doesn't have non-default ACL's for system objects
+ * which had different signatures in the new cluster. Otherwise generates
+ * revoke_objects.sql.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ char subquery[QUERY_ALLOC];
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ prep_status("Checking for system objects to grant or revoke privileges");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+ /*
+ * The old cluster doesn't have system objects with non-default ACL so
+ * quickly exit.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "revoke_objects.sql");
+
+ snprintf(subquery, sizeof(subquery),
+ /* Get system relations which created in pg_catalog */
+ "SELECT 'pg_class'::regclass classid, oid objid, 0 objsubid "
+ "FROM pg_catalog.pg_class "
+ "WHERE relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system relations attributes which created in pg_catalog */
+ "SELECT 'pg_class'::regclass, att.attrelid, att.attnum "
+ "FROM pg_catalog.pg_class rel "
+ "INNER JOIN pg_catalog.pg_attribute att ON rel.oid = att.attrelid "
+ "WHERE rel.relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system functions and procedure which created in pg_catalog */
+ "SELECT 'pg_proc'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_proc "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /*
+ * Get system languages using pg_depend, since they are schema agnostic.
+ */
+ "SELECT refclassid, refobjid, refobjsubid "
+ "FROM pg_catalog.pg_depend "
+ "WHERE deptype = 'p' AND refclassid = 'pg_language'::regclass");
+
+ conn = connectToServer(&new_cluster, "template1");
+ res = executeQueryOrDie(conn,
+ "SELECT ident.type, ident.identity "
+ "FROM (%s) obj, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " obj.classid, obj.objid, obj.objsubid) ident "
+ /*
+ * Don't rely on database collation, since we use strcmp
+ * comparison to find non-default ACLs.
+ */
+ "ORDER BY ident.identity COLLATE \"C\";", subquery);
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ * For every database check system objects with non-default ACL.
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool report = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(aclinfo->obj_ident, PQgetvalue(res, objnum, i_obj_ident));
+
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ {
+ report = true;
+ break;
+ }
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ objnum++;
+ break;
+ }
+ else
+ objnum++;
+ }
+
+ if (report)
+ {
+ found_changed = true;
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n",
+ output_path, strerror(errno));
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+ /* Handle columns separately */
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ {
+ char *pdot = last_dot_location(aclinfo->obj_ident);
+ PQExpBufferData ident_buf;
+
+ if (pdot == NULL || *(pdot + 1) == '\0')
+ pg_fatal("invalid column identity \"%s\"",
+ aclinfo->obj_ident);
+
+ initPQExpBuffer(&ident_buf);
+ appendBinaryPQExpBuffer(&ident_buf, aclinfo->obj_ident,
+ pdot - aclinfo->obj_ident);
+
+ fprintf(script, "REVOKE ALL (%s) ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ pdot + 1, ident_buf.data,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ termPQExpBuffer(&ident_buf);
+ }
+ /*
+ * For relations except sequences we don't need to specify
+ * the object type.
+ */
+ else if (aclinfo->is_relation &&
+ strcmp(aclinfo->obj_type, "sequence") != 0)
+ fprintf(script, "REVOKE ALL ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ /* Other object types */
+ else
+ fprintf(script, "REVOKE ALL ON %s %s FROM %s;\n",
+ aclinfo->obj_type,
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* create_script_for_cluster_analyze()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 7e524ea192..460f400110 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,119 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Gets AclInfo array of system functions, procedures and columns information
+ * which have non-default ACL.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos;
+ AclInfo *curr;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_rolname,
+ i_is_relation;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get relations, attributes, functions and procedures. Some system
+ * objects like views are not pinned, but these type of objects are
+ * created in pg_catalog schema.
+ */
+ "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, "
+ " CASE WHEN shd.classid = 'pg_class'::regclass THEN true "
+ " ELSE false "
+ " END is_relation "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj "
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid IN ('pg_proc'::regclass, 'pg_class'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ "UNION ALL "
+ /*
+ * Get system languages, they are pinned and we can use pg_depend
+ * here.
+ */
+ "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, false "
+ "FROM pg_catalog.pg_shdepend shd "
+ "INNER JOIN pg_catalog.pg_depend d ON d.refclassid = shd.classid "
+ " AND d.refobjid = shd.objid AND d.refobjsubid = shd.objsubid "
+ /* get only pinned system objects */
+ " AND d.deptype = 'p', "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj "
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid = 'pg_language'::regclass "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ */
+ "ORDER BY 2;", dbinfo->db_oid, dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_rolname = PQfnumber(res, "rolename");
+ i_is_relation = PQfnumber(res, "is_relation");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBufferData roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+ curr->is_relation = PQgetvalue(res, aclnum, i_is_relation)[0] == 't';
+
+ initPQExpBuffer(&roles_buf);
+ /* Group all role names by objects type and identity */
+ while (aclnum < PQntuples(res) && //unneeded clause
+ strcmp(curr->obj_ident, PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf.len != 0)
+ appendPQExpBufferChar(&roles_buf, ',');
+
+ appendPQExpBufferStr(&roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+
+ curr->role_names = roles_buf.data;
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -595,6 +710,7 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +736,21 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+ pg_free(acl_arr->aclinfos);
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 8b90cefbe0..0bb75fd785 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -147,6 +147,24 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Structure to store objects information to check if it changed its signature.
+ */
+typedef struct
+{
+ char *obj_type; /* type name */
+ char *obj_ident; /* complete object identity */
+ bool is_relation; /* is the object relation */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -183,6 +201,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -390,6 +410,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
test_rename_catalog_objectstext/plain; charset=UTF-8; name=test_rename_catalog_objectsDownload
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index a51153236a..460c6afa66 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -68,7 +68,7 @@ CATALOG_HEADERS := \
pg_foreign_table.h pg_policy.h pg_replication_origin.h \
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
- pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
+ pg_sequence.h pg_publication.h pg_publication_rel.h pg_sub.h \
pg_subscription_rel.h
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index ea5666ebb8..75d5773672 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -50,7 +50,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 6b104695c0..3022b2b029 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -38,7 +38,7 @@
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/toasting.h"
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index d07bb4496e..2eab802176 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 5d64791c5d..46f2466aed 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -42,7 +42,7 @@ SET search_path TO information_schema;
/* Expand any 1-D array into a set with integers 1..N */
CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
RETURNS SETOF RECORD
- LANGUAGE sql STRICT IMMUTABLE PARALLEL SAFE
+ LANGUAGE pgsql STRICT IMMUTABLE PARALLEL SAFE
AS 'select $1[s], s - pg_catalog.array_lower($1,1) + 1
from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
pg_catalog.array_upper($1,1),
@@ -51,7 +51,7 @@ CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
/* Given an index's OID and an underlying-table column number, return the
* column's position in the index (NULL if not there) */
CREATE FUNCTION _pg_index_position(oid, smallint) RETURNS int
- LANGUAGE sql STRICT STABLE
+ LANGUAGE pgsql STRICT STABLE
AS $$
SELECT (ss.a).n FROM
(SELECT information_schema._pg_expandarray(indkey) AS a
@@ -60,7 +60,7 @@ SELECT (ss.a).n FROM
$$;
CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -68,7 +68,7 @@ CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
$$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typbasetype ELSE $1.atttypid END$$;
CREATE FUNCTION _pg_truetypmod(pg_attribute, pg_type) RETURNS int4
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -78,7 +78,7 @@ $$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typtypmod ELSE $1.atttypmod END$$;
-- these functions encapsulate knowledge about the encoding of typmod:
CREATE FUNCTION _pg_char_max_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -94,7 +94,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_char_octet_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -110,7 +110,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -131,7 +131,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision_radix(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -143,7 +143,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_scale(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -159,7 +159,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_datetime_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -175,7 +175,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_interval_type(typid oid, mod int4) RETURNS text
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -1477,7 +1477,7 @@ CREATE VIEW routines AS
CAST(null AS cardinal_number) AS maximum_cardinality,
CAST(CASE WHEN p.prokind <> 'p' THEN 0 END AS sql_identifier) AS dtd_identifier,
- CAST(CASE WHEN l.lanname = 'sql' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
+ CAST(CASE WHEN l.lanname = 'pgsql' THEN 'PGSQL' ELSE 'EXTERNAL' END AS character_data)
AS routine_body,
CAST(
CASE WHEN pg_has_role(p.proowner, 'USAGE') THEN p.prosrc ELSE null END
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index ae3002bb42..39c803fa00 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -52,7 +52,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
@@ -505,10 +505,10 @@ static const ObjectPropertyType ObjectProperty[] =
SubscriptionObjectIndexId,
SUBSCRIPTIONOID,
SUBSCRIPTIONNAME,
- Anum_pg_subscription_oid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_oid,
+ Anum_pg_sub_subname,
InvalidAttrNumber,
- Anum_pg_subscription_subowner,
+ Anum_pg_sub_subowner,
InvalidAttrNumber,
OBJECT_SUBSCRIPTION,
true
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 59f97bf3d0..900acb90a3 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -40,7 +40,7 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index 68d88ff499..c93e7037fc 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -20,7 +20,7 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/indexing.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
@@ -64,12 +64,12 @@ GetSubscription(Oid subid, bool missing_ok)
sub->dbid = subform->subdbid;
sub->name = pstrdup(NameStr(subform->subname));
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subconninfo,
+ Anum_pg_sub_subconn,
&isnull);
Assert(!isnull);
sub->conninfo = TextDatumGetCString(datum);
@@ -77,7 +77,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subslotname,
+ Anum_pg_sub_subslotname,
&isnull);
if (!isnull)
sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));
@@ -87,7 +87,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get synccommit */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subsynccommit,
+ Anum_pg_sub_subsynccommit,
&isnull);
Assert(!isnull);
sub->synccommit = TextDatumGetCString(datum);
@@ -95,7 +95,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get publications */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subpublications,
+ Anum_pg_sub_subpublications,
&isnull);
Assert(!isnull);
sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
@@ -121,7 +121,7 @@ CountDBSubscriptions(Oid dbid)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- Anum_pg_subscription_subdbid,
+ Anum_pg_sub_subdbid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
@@ -163,7 +163,7 @@ get_subscription_oid(const char *subname, bool missing_ok)
{
Oid oid;
- oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(subname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index f7800f01a6..20597dd1ff 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -477,7 +477,7 @@ SELECT
l.provider, l.label
FROM
pg_shseclabel l
- JOIN pg_subscription s ON l.classoid = s.tableoid AND l.objoid = s.oid
+ JOIN pg_sub s ON l.classoid = s.tableoid AND l.objoid = s.oid
UNION ALL
SELECT
l.objoid, l.classoid, 0::int4 AS objsubid,
@@ -803,19 +803,19 @@ CREATE VIEW pg_stat_wal_receiver AS
FROM pg_stat_get_wal_receiver() s
WHERE s.pid IS NOT NULL;
-CREATE VIEW pg_stat_subscription AS
+CREATE VIEW pg_stat_sub AS
SELECT
su.oid AS subid,
su.subname,
st.pid,
st.relid,
- st.received_lsn,
+ st.received_lsn received_location,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_lsn latest_end_location,
st.latest_end_time
- FROM pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL) st
+ FROM pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL) st
ON (st.subid = su.oid);
CREATE VIEW pg_stat_ssl AS
@@ -1062,9 +1062,9 @@ CREATE VIEW pg_replication_origin_status AS
REVOKE ALL ON pg_replication_origin_status FROM public;
-- All columns of pg_subscription except subconninfo are readable.
-REVOKE ALL ON pg_subscription FROM public;
-GRANT SELECT (subdbid, subname, subowner, subenabled, subslotname, subpublications)
- ON pg_subscription TO public;
+REVOKE ALL ON pg_sub FROM public;
+GRANT SELECT (subdbid, subname, subowner, subactive, subslotname, subpublications)
+ ON pg_sub TO public;
--
@@ -1114,7 +1114,7 @@ FROM pg_catalog.ts_parse(
) AS tt
WHERE tt.tokid = parse.tokid
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(regconfig,text) IS
'debug function for text search configuration';
@@ -1130,7 +1130,7 @@ RETURNS SETOF record AS
$$
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1);
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(text) IS
'debug function for current text search configuration';
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index d425ef935e..9429356e81 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -35,7 +35,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index a70e75a219..2b3bf4c888 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -38,7 +38,7 @@
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 5408edcfc2..911265ff6f 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -23,7 +23,7 @@
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
@@ -309,8 +309,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
Relation rel;
ObjectAddress myself;
Oid subid;
- bool nulls[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
Oid owner = GetUserId();
HeapTuple tup;
bool connect;
@@ -361,7 +361,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Check if name is used */
- subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(stmt->subname));
if (OidIsValid(subid))
{
@@ -392,23 +392,23 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
memset(nulls, false, sizeof(nulls));
subid = GetNewOidWithIndex(rel, SubscriptionObjectIndexId,
- Anum_pg_subscription_oid);
- values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
- values[Anum_pg_subscription_subname - 1] =
+ Anum_pg_sub_oid);
+ values[Anum_pg_sub_oid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
+ values[Anum_pg_sub_subname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
- values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
- values[Anum_pg_subscription_subenabled - 1] = BoolGetDatum(enabled);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subowner - 1] = ObjectIdGetDatum(owner);
+ values[Anum_pg_sub_subactive - 1] = BoolGetDatum(enabled);
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(conninfo);
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- values[Anum_pg_subscription_subsynccommit - 1] =
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(publications);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -623,9 +623,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
{
Relation rel;
ObjectAddress myself;
- bool nulls[Natts_pg_subscription];
- bool replaces[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ bool replaces[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
HeapTuple tup;
Oid subid;
bool update_tuple = false;
@@ -683,18 +683,18 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
"slot_name = NONE")));
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- replaces[Anum_pg_subscription_subslotname - 1] = true;
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ replaces[Anum_pg_sub_subslotname - 1] = true;
}
if (synchronous_commit)
{
- values[Anum_pg_subscription_subsynccommit - 1] =
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- replaces[Anum_pg_subscription_subsynccommit - 1] = true;
+ replaces[Anum_pg_sub_subsynccommit - 1] = true;
}
update_tuple = true;
@@ -716,9 +716,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot enable subscription that does not have a slot name")));
- values[Anum_pg_subscription_subenabled - 1] =
+ values[Anum_pg_sub_subactive - 1] =
BoolGetDatum(enabled);
- replaces[Anum_pg_subscription_subenabled - 1] = true;
+ replaces[Anum_pg_sub_subactive - 1] = true;
if (enabled)
ApplyLauncherWakeupAtCommit();
@@ -733,9 +733,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
/* Check the connection info string. */
walrcv_check_conninfo(stmt->conninfo);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(stmt->conninfo);
- replaces[Anum_pg_subscription_subconninfo - 1] = true;
+ replaces[Anum_pg_sub_subconn - 1] = true;
update_tuple = true;
break;
@@ -748,9 +748,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
NULL, NULL, NULL, ©_data,
NULL, &refresh);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(stmt->publication);
- replaces[Anum_pg_subscription_subpublications - 1] = true;
+ replaces[Anum_pg_sub_subpublications - 1] = true;
update_tuple = true;
@@ -884,19 +884,19 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
/* Get subname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subname, &isnull);
+ Anum_pg_sub_subname, &isnull);
Assert(!isnull);
subname = pstrdup(NameStr(*DatumGetName(datum)));
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subconninfo, &isnull);
+ Anum_pg_sub_subconn, &isnull);
Assert(!isnull);
conninfo = TextDatumGetCString(datum);
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subslotname, &isnull);
+ Anum_pg_sub_subslotname, &isnull);
if (!isnull)
slotname = pstrdup(NameStr(*DatumGetName(datum)));
else
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 4643af95fe..23b8df943b 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -22,7 +22,7 @@
#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "funcapi.h"
#include "libpq/pqsignal.h"
@@ -97,7 +97,7 @@ static volatile sig_atomic_t got_SIGHUP = false;
static bool on_commit_launcher_wakeup = false;
-Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
+Datum pg_stat_get_sub(PG_FUNCTION_ARGS);
/*
@@ -149,7 +149,7 @@ get_subscription_list(void)
sub->oid = subform->oid;
sub->dbid = subform->subdbid;
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->name = pstrdup(NameStr(subform->subname));
/* We don't fill fields we are not interested in. */
@@ -1084,7 +1084,7 @@ IsLogicalLauncher(void)
* Returns state of the subscriptions.
*/
Datum
-pg_stat_get_subscription(PG_FUNCTION_ARGS)
+pg_stat_get_sub(PG_FUNCTION_ARGS)
{
#define PG_STAT_GET_SUBSCRIPTION_COLS 8
Oid subid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index ced0d191c2..67cab841dd 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -29,7 +29,7 @@
#include "access/xlog_internal.h"
#include "catalog/catalog.h"
#include "catalog/namespace.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "commands/tablecmds.h"
#include "commands/trigger.h"
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 50f8912c13..9330d78c8a 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -59,7 +59,7 @@
#include "catalog/pg_rewrite.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
@@ -117,7 +117,7 @@ static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_
static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
-static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_subscription] = {Schema_pg_subscription};
+static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_sub] = {Schema_pg_sub};
/*
* Hash tables that index the relation cache
@@ -3648,8 +3648,8 @@ RelationCacheInitializePhase2(void)
Natts_pg_auth_members, Desc_pg_auth_members);
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
Natts_pg_shseclabel, Desc_pg_shseclabel);
- formrdesc("pg_subscription", SubscriptionRelation_Rowtype_Id, true,
- Natts_pg_subscription, Desc_pg_subscription);
+ formrdesc("pg_sub", SubscriptionRelation_Rowtype_Id, true,
+ Natts_pg_sub, Desc_pg_subscription);
#define NUM_CRITICAL_SHARED_RELS 5 /* fix if you change list above */
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index d69c0ff813..d021d37fba 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -63,7 +63,7 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
@@ -776,8 +776,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionNameIndexId,
2,
{
- Anum_pg_subscription_subdbid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_subdbid,
+ Anum_pg_sub_subname,
0,
0
},
@@ -787,7 +787,7 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionObjectIndexId,
1,
{
- Anum_pg_subscription_oid,
+ Anum_pg_sub_oid,
0,
0,
0
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 08658c8e86..cca150a39c 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4117,7 +4117,7 @@ getSubscriptions(Archive *fout)
int n;
res = ExecuteSqlQuery(fout,
- "SELECT count(*) FROM pg_subscription "
+ "SELECT count(*) FROM pg_sub "
"WHERE subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
PGRES_TUPLES_OK);
@@ -4136,9 +4136,9 @@ getSubscriptions(Archive *fout)
appendPQExpBuffer(query,
"SELECT s.tableoid, s.oid, s.subname,"
"(%s s.subowner) AS rolname, "
- " s.subconninfo, s.subslotname, s.subsynccommit, "
+ " s.subconn, s.subslotname, s.subsynccommit, "
" s.subpublications "
- "FROM pg_subscription s "
+ "FROM pg_sub s "
"WHERE s.subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
username_subquery);
@@ -4150,7 +4150,7 @@ getSubscriptions(Archive *fout)
i_oid = PQfnumber(res, "oid");
i_subname = PQfnumber(res, "subname");
i_rolname = PQfnumber(res, "rolname");
- i_subconninfo = PQfnumber(res, "subconninfo");
+ i_subconninfo = PQfnumber(res, "subconn");
i_subslotname = PQfnumber(res, "subslotname");
i_subsynccommit = PQfnumber(res, "subsynccommit");
i_subpublications = PQfnumber(res, "subpublications");
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index ef4445b017..8d4c8d8eb5 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -357,10 +357,10 @@ DECLARE_UNIQUE_INDEX(pg_publication_rel_oid_index, 6112, on pg_publication_rel u
DECLARE_UNIQUE_INDEX(pg_publication_rel_prrelid_prpubid_index, 6113, on pg_publication_rel using btree(prrelid oid_ops, prpubid oid_ops));
#define PublicationRelPrrelidPrpubidIndexId 6113
-DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_sub using btree(oid oid_ops));
#define SubscriptionObjectIndexId 6114
-DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_sub using btree(subdbid oid_ops, subname name_ops));
#define SubscriptionNameIndexId 6115
DECLARE_UNIQUE_INDEX(pg_subscription_rel_srrelid_srsubid_index, 6117, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
diff --git a/src/include/catalog/pg_language.dat b/src/include/catalog/pg_language.dat
index 02dde38a1c..5c82c1b545 100644
--- a/src/include/catalog/pg_language.dat
+++ b/src/include/catalog/pg_language.dat
@@ -20,6 +20,6 @@
lanname => 'c', lanvalidator => 'fmgr_c_validator' },
{ oid => '14', oid_symbol => 'SQLlanguageId',
descr => 'SQL-language functions',
- lanname => 'sql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
+ lanname => 'pgsql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
]
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index ac8f64b219..27a80a6a5f 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2281,7 +2281,7 @@
proname => 'justify_days', prorettype => 'interval',
proargtypes => 'interval', prosrc => 'interval_justify_days' },
{ oid => '1176', descr => 'convert date and time to timestamp with time zone',
- proname => 'timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'date time',
prosrc => 'select cast(($1 + $2) as timestamp with time zone)' },
{ oid => '1178', descr => 'convert timestamp with time zone to date',
@@ -2334,16 +2334,16 @@
prosrc => 'interval_scale' },
{ oid => '1215', descr => 'get description for object id and catalog name',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0' },
{ oid => '1216', descr => 'get description for table column',
- proname => 'col_description', prolang => 'sql', procost => '100',
+ proname => 'col_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'pg_catalog.pg_class\'::pg_catalog.regclass and objsubid = $2' },
{ oid => '1993',
descr => 'get description for object id and shared catalog name',
- proname => 'shobj_description', prolang => 'sql', procost => '100',
+ proname => 'shobj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP)' },
@@ -2519,13 +2519,13 @@
prosrc => 'hashtidextended' },
{ oid => '1296',
- proname => 'timedate_pl', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'timedate_pl', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'time date', prosrc => 'select ($2 + $1)' },
{ oid => '1297',
proname => 'datetimetz_pl', prorettype => 'timestamptz',
proargtypes => 'date timetz', prosrc => 'datetimetz_timestamptz' },
{ oid => '1298',
- proname => 'timetzdate_pl', prolang => 'sql', prorettype => 'timestamptz',
+ proname => 'timetzdate_pl', prolang => 'pgsql', prorettype => 'timestamptz',
proargtypes => 'timetz date', prosrc => 'select ($2 + $1)' },
{ oid => '1299', descr => 'current transaction time',
proname => 'now', provolatile => 's', prorettype => 'timestamptz',
@@ -2567,17 +2567,17 @@
proargtypes => 'timestamptz timestamptz timestamptz timestamptz',
prosrc => 'overlaps_timestamp' },
{ oid => '1305', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1306', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz timestamptz timestamptz interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1307', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz timestamptz',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2586,15 +2586,15 @@
proname => 'overlaps', proisstrict => 'f', prorettype => 'bool',
proargtypes => 'time time time time', prosrc => 'overlaps_time' },
{ oid => '1309', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1310', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time time time interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1311', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time time',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2675,7 +2675,7 @@
# This form of obj_description is now deprecated, since it will fail if
# OIDs are not unique across system catalogs. Use the other form instead.
{ oid => '1348', descr => 'deprecated, use two-argument form instead',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and objsubid = 0' },
@@ -2759,7 +2759,7 @@
prosrc => 'textlen' },
{ oid => '1384', descr => 'extract field from date',
- proname => 'date_part', prolang => 'sql', prorettype => 'float8',
+ proname => 'date_part', prolang => 'pgsql', prorettype => 'float8',
proargtypes => 'text date',
prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time zone))' },
{ oid => '1385', descr => 'extract field from time',
@@ -2767,7 +2767,7 @@
prosrc => 'time_part' },
{ oid => '1386',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp with time zone), $1)' },
@@ -2882,7 +2882,7 @@
proname => 'box_div', prorettype => 'box', proargtypes => 'box point',
prosrc => 'box_div' },
{ oid => '1426',
- proname => 'path_contain_pt', prolang => 'sql', prorettype => 'bool',
+ proname => 'path_contain_pt', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'path point', prosrc => 'select pg_catalog.on_ppath($2, $1)' },
{ oid => '1428',
proname => 'poly_contain_pt', prorettype => 'bool',
@@ -3142,7 +3142,7 @@
proname => 'center', prorettype => 'point', proargtypes => 'circle',
prosrc => 'circle_center' },
{ oid => '1544', descr => 'convert circle to 12-vertex polygon',
- proname => 'polygon', prolang => 'sql', prorettype => 'polygon',
+ proname => 'polygon', prolang => 'pgsql', prorettype => 'polygon',
proargtypes => 'circle', prosrc => 'select pg_catalog.polygon(12, $1)' },
{ oid => '1545', descr => 'number of points',
proname => 'npoints', prorettype => 'int4', proargtypes => 'path',
@@ -3438,11 +3438,11 @@
proname => 'translate', prorettype => 'text', proargtypes => 'text text text',
prosrc => 'translate' },
{ oid => '879', descr => 'left-pad string to length',
- proname => 'lpad', prolang => 'sql', prorettype => 'text',
+ proname => 'lpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.lpad($1, $2, \' \')' },
{ oid => '880', descr => 'right-pad string to length',
- proname => 'rpad', prolang => 'sql', prorettype => 'text',
+ proname => 'rpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.rpad($1, $2, \' \')' },
{ oid => '881', descr => 'trim spaces from left end of string',
@@ -4033,7 +4033,7 @@
proname => 'inetpl', prorettype => 'inet', proargtypes => 'inet int8',
prosrc => 'inetpl' },
{ oid => '2631',
- proname => 'int8pl_inet', prolang => 'sql', prorettype => 'inet',
+ proname => 'int8pl_inet', prolang => 'pgsql', prorettype => 'inet',
proargtypes => 'int8 inet', prosrc => 'select $2 + $1' },
{ oid => '2632',
proname => 'inetmi_int8', prorettype => 'inet', proargtypes => 'inet int8',
@@ -4165,13 +4165,13 @@
proname => 'round', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_round' },
{ oid => '1708', descr => 'value rounded to \'scale\' of zero',
- proname => 'round', prolang => 'sql', prorettype => 'numeric',
+ proname => 'round', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.round($1,0)' },
{ oid => '1709', descr => 'value truncated to \'scale\'',
proname => 'trunc', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_trunc' },
{ oid => '1710', descr => 'value truncated to \'scale\' of zero',
- proname => 'trunc', prolang => 'sql', prorettype => 'numeric',
+ proname => 'trunc', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.trunc($1,0)' },
{ oid => '1711', descr => 'nearest integer >= value',
proname => 'ceil', prorettype => 'numeric', proargtypes => 'numeric',
@@ -4258,10 +4258,10 @@
proname => 'numeric', prorettype => 'numeric', proargtypes => 'int4',
prosrc => 'int4_numeric' },
{ oid => '1741', descr => 'base 10 logarithm',
- proname => 'log', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1481', descr => 'base 10 logarithm',
- proname => 'log10', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log10', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1742', descr => 'convert float4 to numeric',
proname => 'numeric', prorettype => 'numeric', proargtypes => 'float4',
@@ -4394,7 +4394,7 @@
proname => 'quote_literal', prorettype => 'text', proargtypes => 'text',
prosrc => 'quote_literal' },
{ oid => '1285', descr => 'quote a data value for usage in a querystring',
- proname => 'quote_literal', prolang => 'sql', provolatile => 's',
+ proname => 'quote_literal', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_literal($1::pg_catalog.text)' },
{ oid => '1289',
@@ -4403,7 +4403,7 @@
proargtypes => 'text', prosrc => 'quote_nullable' },
{ oid => '1290',
descr => 'quote a possibly-null data value for usage in a querystring',
- proname => 'quote_nullable', prolang => 'sql', proisstrict => 'f',
+ proname => 'quote_nullable', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_nullable($1::pg_catalog.text)' },
@@ -4442,13 +4442,13 @@
prorettype => 'text', proargtypes => 'text', prosrc => 'text_format_nv' },
{ oid => '1810', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bytea', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1811', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'text', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1812', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bit', prosrc => 'select pg_catalog.length($1)' },
# Selectivity estimators for LIKE and related operators
@@ -4767,7 +4767,7 @@
prosrc => 'to_ascii_encname' },
{ oid => '1848',
- proname => 'interval_pl_time', prolang => 'sql', prorettype => 'time',
+ proname => 'interval_pl_time', prolang => 'pgsql', prorettype => 'time',
proargtypes => 'interval time', prosrc => 'select $2 + $1' },
{ oid => '1850',
@@ -5178,12 +5178,12 @@
proargnames => '{pid,status,receive_start_lsn,receive_start_tli,received_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
prosrc => 'pg_stat_get_wal_receiver' },
{ oid => '6118', descr => 'statistics: information about subscription',
- proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
+ proname => 'pg_stat_get_sub', proisstrict => 'f', provolatile => 's',
proparallel => 'r', prorettype => 'record', proargtypes => 'oid',
proallargtypes => '{oid,oid,oid,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}',
proargmodes => '{i,o,o,o,o,o,o,o,o}',
proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}',
- prosrc => 'pg_stat_get_subscription' },
+ prosrc => 'pg_stat_get_sub' },
{ oid => '2026', descr => 'statistics: current backend PID',
proname => 'pg_backend_pid', provolatile => 's', proparallel => 'r',
prorettype => 'int4', proargtypes => '', prosrc => 'pg_backend_pid' },
@@ -5579,11 +5579,11 @@
proargtypes => 'timetz int4', prosrc => 'timetz_scale' },
{ oid => '2003',
- proname => 'textanycat', prolang => 'sql', provolatile => 's',
+ proname => 'textanycat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'text anynonarray',
prosrc => 'select $1 || $2::pg_catalog.text' },
{ oid => '2004',
- proname => 'anytextcat', prolang => 'sql', provolatile => 's',
+ proname => 'anytextcat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anynonarray text',
prosrc => 'select $1::pg_catalog.text || $2' },
@@ -5683,15 +5683,15 @@
proargtypes => 'timestamp timestamp timestamp timestamp',
prosrc => 'overlaps_timestamp' },
{ oid => '2042', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '2043', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp timestamp timestamp interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '2044', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp timestamp',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
{ oid => '2045', descr => 'less-equal-greater',
@@ -5757,7 +5757,7 @@
proargtypes => 'timestamp timestamp', prosrc => 'timestamp_age' },
{ oid => '2059',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamp',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp without time zone), $1)' },
@@ -5778,7 +5778,7 @@
proname => 'substring', prorettype => 'text', proargtypes => 'text text',
prosrc => 'textregexsubstr' },
{ oid => '2074', descr => 'extract text matching SQL regular expression',
- proname => 'substring', prolang => 'sql', prorettype => 'text',
+ proname => 'substring', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text text text',
prosrc => 'select pg_catalog.substring($1, pg_catalog.similar_to_escape($2, $3))' },
@@ -6117,11 +6117,11 @@
proname => 'pg_sleep', provolatile => 'v', prorettype => 'void',
proargtypes => 'float8', prosrc => 'pg_sleep' },
{ oid => '3935', descr => 'sleep for the specified interval',
- proname => 'pg_sleep_for', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_for', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'interval',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from pg_catalog.clock_timestamp() operator(pg_catalog.+) $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '3936', descr => 'sleep until the specified time',
- proname => 'pg_sleep_until', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_until', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '315', descr => 'Is JIT compilation available in this session?',
@@ -6922,7 +6922,7 @@
proargtypes => 'name', prosrc => 'pg_database_size_name' },
{ oid => '2325',
descr => 'disk space usage for the main fork of the specified table or index',
- proname => 'pg_relation_size', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_relation_size', prolang => 'pgsql', provolatile => 'v',
prorettype => 'int8', proargtypes => 'regclass',
prosrc => 'select pg_catalog.pg_relation_size($1, \'main\')' },
{ oid => '2332',
@@ -7760,21 +7760,21 @@
# formerly-missing interval + datetime operators
{ oid => '2546',
- proname => 'interval_pl_date', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'interval_pl_date', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'interval date', prosrc => 'select $2 + $1' },
{ oid => '2547',
- proname => 'interval_pl_timetz', prolang => 'sql', prorettype => 'timetz',
+ proname => 'interval_pl_timetz', prolang => 'pgsql', prorettype => 'timetz',
proargtypes => 'interval timetz', prosrc => 'select $2 + $1' },
{ oid => '2548',
- proname => 'interval_pl_timestamp', prolang => 'sql',
+ proname => 'interval_pl_timestamp', prolang => 'pgsql',
prorettype => 'timestamp', proargtypes => 'interval timestamp',
prosrc => 'select $2 + $1' },
{ oid => '2549',
- proname => 'interval_pl_timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'interval_pl_timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'interval timestamptz',
prosrc => 'select $2 + $1' },
{ oid => '2550',
- proname => 'integer_pl_date', prolang => 'sql', prorettype => 'date',
+ proname => 'integer_pl_date', prolang => 'pgsql', prorettype => 'date',
proargtypes => 'int4 date', prosrc => 'select $2 + $1' },
{ oid => '2556', descr => 'get OIDs of databases in a tablespace',
@@ -8163,7 +8163,7 @@
proname => 'xpath', prorettype => '_xml', proargtypes => 'text xml _text',
prosrc => 'xpath' },
{ oid => '2932', descr => 'evaluate XPath expression',
- proname => 'xpath', prolang => 'sql', prorettype => '_xml',
+ proname => 'xpath', prolang => 'pgsql', prorettype => '_xml',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath($1, $2, \'{}\'::pg_catalog.text[])' },
@@ -8176,7 +8176,7 @@
proname => 'xpath_exists', prorettype => 'bool',
proargtypes => 'text xml _text', prosrc => 'xpath_exists' },
{ oid => '3050', descr => 'test XML value against XPath expression',
- proname => 'xpath_exists', prolang => 'sql', prorettype => 'bool',
+ proname => 'xpath_exists', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '3051', descr => 'determine if a string is well formed XML',
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_sub.h
similarity index 90%
rename from src/include/catalog/pg_subscription.h
rename to src/include/catalog/pg_sub.h
index 3cb13d897e..6628814833 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_sub.h
@@ -18,7 +18,7 @@
#define PG_SUBSCRIPTION_H
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_d.h"
+#include "catalog/pg_sub_d.h"
#include "nodes/pg_list.h"
@@ -36,7 +36,7 @@
*
* NOTE: When adding a column, also update system_views.sql.
*/
-CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
+CATALOG(pg_sub,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
@@ -45,12 +45,12 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
Oid subowner; /* Owner of the subscription */
- bool subenabled; /* True if the subscription is enabled (the
+ bool subactive; /* True if the subscription is enabled (the
* worker should be running) */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* Connection string to the publisher */
- text subconninfo BKI_FORCE_NOT_NULL;
+ text subconn BKI_FORCE_NOT_NULL;
/* Slot name on publisher */
NameData subslotname;
diff --git a/src/include/catalog/toasting.h b/src/include/catalog/toasting.h
index cc5dfed0bf..40a0c901cd 100644
--- a/src/include/catalog/toasting.h
+++ b/src/include/catalog/toasting.h
@@ -98,7 +98,7 @@ DECLARE_TOAST(pg_shdescription, 2846, 2847);
DECLARE_TOAST(pg_shseclabel, 4060, 4061);
#define PgShseclabelToastTable 4060
#define PgShseclabelToastIndex 4061
-DECLARE_TOAST(pg_subscription, 4183, 4184);
+DECLARE_TOAST(pg_sub, 4183, 4184);
#define PgSubscriptionToastTable 4183
#define PgSubscriptionToastIndex 4184
DECLARE_TOAST(pg_tablespace, 4185, 4186);
diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h
index 05f4936419..d1cf8906a7 100644
--- a/src/include/replication/worker_internal.h
+++ b/src/include/replication/worker_internal.h
@@ -15,7 +15,7 @@
#include <signal.h>
#include "access/xlogdefs.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
On 06.04.2020 16:49, Anastasia Lubennikova wrote:
New version of the patch is attached. I fixed several issues in the
check_for_changed_signatures().Now it passes check without "test_rename_catalog_objects" and fails
(generates script) with it. Test script pg_upgrade_ACL_test.sh
demonstrates this.The only known issue left is the usage of pg_identify_object(), though
I don't see a problem here with object types that this patch involves.
As I updated the code, I will leave this patch in Need Review.
One more fix for free_acl_infos().
Thanks to cfbot.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v8.patchtext/x-patch; charset=UTF-8; name=pg_upgrade_ACL_check_v8.patchDownload
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 00aef855dc..63a216c383 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -142,6 +143,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -161,6 +164,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -443,6 +447,229 @@ check_databases_are_compatible(void)
}
}
+/*
+ * Find the location of the last dot, return NULL if not found.
+ */
+static char *
+last_dot_location(const char *identity)
+{
+ const char *p,
+ *ret = NULL;
+
+ for (p = identity; *p; p++)
+ if (*p == '.')
+ ret = p;
+ return unconstify(char *, ret);
+}
+
+/*
+ * check_for_changed_signatures()
+ *
+ * Checks that the old cluster doesn't have non-default ACL's for system objects
+ * which had different signatures in the new cluster. Otherwise generates
+ * revoke_objects.sql.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ char subquery[QUERY_ALLOC];
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ prep_status("Checking for system objects to grant or revoke privileges");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+ /*
+ * The old cluster doesn't have system objects with non-default ACL so
+ * quickly exit.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "revoke_objects.sql");
+
+ snprintf(subquery, sizeof(subquery),
+ /* Get system relations which created in pg_catalog */
+ "SELECT 'pg_class'::regclass classid, oid objid, 0 objsubid "
+ "FROM pg_catalog.pg_class "
+ "WHERE relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system relations attributes which created in pg_catalog */
+ "SELECT 'pg_class'::regclass, att.attrelid, att.attnum "
+ "FROM pg_catalog.pg_class rel "
+ "INNER JOIN pg_catalog.pg_attribute att ON rel.oid = att.attrelid "
+ "WHERE rel.relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system functions and procedure which created in pg_catalog */
+ "SELECT 'pg_proc'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_proc "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /*
+ * Get system languages using pg_depend, since they are schema agnostic.
+ */
+ "SELECT refclassid, refobjid, refobjsubid "
+ "FROM pg_catalog.pg_depend "
+ "WHERE deptype = 'p' AND refclassid = 'pg_language'::regclass");
+
+ conn = connectToServer(&new_cluster, "template1");
+ res = executeQueryOrDie(conn,
+ "SELECT ident.type, ident.identity "
+ "FROM (%s) obj, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " obj.classid, obj.objid, obj.objsubid) ident "
+ /*
+ * Don't rely on database collation, since we use strcmp
+ * comparison to find non-default ACLs.
+ */
+ "ORDER BY ident.identity COLLATE \"C\";", subquery);
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ * For every database check system objects with non-default ACL.
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool report = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(aclinfo->obj_ident, PQgetvalue(res, objnum, i_obj_ident));
+
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ {
+ report = true;
+ break;
+ }
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ objnum++;
+ break;
+ }
+ else
+ objnum++;
+ }
+
+ if (report)
+ {
+ found_changed = true;
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n",
+ output_path, strerror(errno));
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+ /* Handle columns separately */
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ {
+ char *pdot = last_dot_location(aclinfo->obj_ident);
+ PQExpBufferData ident_buf;
+
+ if (pdot == NULL || *(pdot + 1) == '\0')
+ pg_fatal("invalid column identity \"%s\"",
+ aclinfo->obj_ident);
+
+ initPQExpBuffer(&ident_buf);
+ appendBinaryPQExpBuffer(&ident_buf, aclinfo->obj_ident,
+ pdot - aclinfo->obj_ident);
+
+ fprintf(script, "REVOKE ALL (%s) ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ pdot + 1, ident_buf.data,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ termPQExpBuffer(&ident_buf);
+ }
+ /*
+ * For relations except sequences we don't need to specify
+ * the object type.
+ */
+ else if (aclinfo->is_relation &&
+ strcmp(aclinfo->obj_type, "sequence") != 0)
+ fprintf(script, "REVOKE ALL ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ /* Other object types */
+ else
+ fprintf(script, "REVOKE ALL ON %s %s FROM %s;\n",
+ aclinfo->obj_type,
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* create_script_for_cluster_analyze()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 7e524ea192..d2bee11ed7 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,120 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Gets AclInfo array of system functions, procedures and columns information
+ * which have non-default ACL.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos;
+ AclInfo *curr;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_rolname,
+ i_is_relation;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get relations, attributes, functions and procedures. Some system
+ * objects like views are not pinned, but these type of objects are
+ * created in pg_catalog schema.
+ */
+ "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, "
+ " CASE WHEN shd.classid = 'pg_class'::regclass THEN true "
+ " ELSE false "
+ " END is_relation "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj "
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid IN ('pg_proc'::regclass, 'pg_class'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ "UNION ALL "
+ /*
+ * Get system languages, they are pinned and we can use pg_depend
+ * here.
+ */
+ "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, false "
+ "FROM pg_catalog.pg_shdepend shd "
+ "INNER JOIN pg_catalog.pg_depend d ON d.refclassid = shd.classid "
+ " AND d.refobjid = shd.objid AND d.refobjsubid = shd.objsubid "
+ /* get only pinned system objects */
+ " AND d.deptype = 'p', "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj "
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid = 'pg_language'::regclass "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ */
+ "ORDER BY 2;", dbinfo->db_oid, dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_rolname = PQfnumber(res, "rolename");
+ i_is_relation = PQfnumber(res, "is_relation");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBufferData roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+ curr->is_relation = PQgetvalue(res, aclnum, i_is_relation)[0] == 't';
+
+ initPQExpBuffer(&roles_buf);
+ /* Group all role names by objects type and identity */
+ while (aclnum < PQntuples(res) &&
+ strcmp(curr->obj_ident, PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf.len != 0)
+ appendPQExpBufferChar(&roles_buf, ',');
+
+ appendPQExpBufferStr(&roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+
+ curr->role_names = roles_buf.data;
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -384,6 +500,9 @@ get_db_infos(ClusterInfo *cluster)
dbinfos[tupnum].db_ctype = pg_strdup(PQgetvalue(res, tupnum, i_datctype));
snprintf(dbinfos[tupnum].db_tablespace, sizeof(dbinfos[tupnum].db_tablespace), "%s",
PQgetvalue(res, tupnum, i_spclocation));
+
+ /* initialize clean array */
+ dbinfos[tupnum].non_def_acl_arr.nacls = 0;
}
PQclear(res);
@@ -595,6 +714,8 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+ if (&db_arr->dbs[dbnum].non_def_acl_arr.nacls > 0)
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +741,21 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+ pg_free(acl_arr->aclinfos);
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 8b90cefbe0..0bb75fd785 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -147,6 +147,24 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Structure to store objects information to check if it changed its signature.
+ */
+typedef struct
+{
+ char *obj_type; /* type name */
+ char *obj_ident; /* complete object identity */
+ bool is_relation; /* is the object relation */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -183,6 +201,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -390,6 +410,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
test_rename_catalog_objectstext/plain; charset=UTF-8; name=test_rename_catalog_objectsDownload
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index a51153236a..460c6afa66 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -68,7 +68,7 @@ CATALOG_HEADERS := \
pg_foreign_table.h pg_policy.h pg_replication_origin.h \
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
- pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
+ pg_sequence.h pg_publication.h pg_publication_rel.h pg_sub.h \
pg_subscription_rel.h
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index ea5666ebb8..75d5773672 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -50,7 +50,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 6b104695c0..3022b2b029 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -38,7 +38,7 @@
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/toasting.h"
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index d07bb4496e..2eab802176 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 5d64791c5d..46f2466aed 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -42,7 +42,7 @@ SET search_path TO information_schema;
/* Expand any 1-D array into a set with integers 1..N */
CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
RETURNS SETOF RECORD
- LANGUAGE sql STRICT IMMUTABLE PARALLEL SAFE
+ LANGUAGE pgsql STRICT IMMUTABLE PARALLEL SAFE
AS 'select $1[s], s - pg_catalog.array_lower($1,1) + 1
from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
pg_catalog.array_upper($1,1),
@@ -51,7 +51,7 @@ CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
/* Given an index's OID and an underlying-table column number, return the
* column's position in the index (NULL if not there) */
CREATE FUNCTION _pg_index_position(oid, smallint) RETURNS int
- LANGUAGE sql STRICT STABLE
+ LANGUAGE pgsql STRICT STABLE
AS $$
SELECT (ss.a).n FROM
(SELECT information_schema._pg_expandarray(indkey) AS a
@@ -60,7 +60,7 @@ SELECT (ss.a).n FROM
$$;
CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -68,7 +68,7 @@ CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
$$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typbasetype ELSE $1.atttypid END$$;
CREATE FUNCTION _pg_truetypmod(pg_attribute, pg_type) RETURNS int4
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -78,7 +78,7 @@ $$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typtypmod ELSE $1.atttypmod END$$;
-- these functions encapsulate knowledge about the encoding of typmod:
CREATE FUNCTION _pg_char_max_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -94,7 +94,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_char_octet_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -110,7 +110,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -131,7 +131,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision_radix(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -143,7 +143,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_scale(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -159,7 +159,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_datetime_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -175,7 +175,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_interval_type(typid oid, mod int4) RETURNS text
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -1477,7 +1477,7 @@ CREATE VIEW routines AS
CAST(null AS cardinal_number) AS maximum_cardinality,
CAST(CASE WHEN p.prokind <> 'p' THEN 0 END AS sql_identifier) AS dtd_identifier,
- CAST(CASE WHEN l.lanname = 'sql' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
+ CAST(CASE WHEN l.lanname = 'pgsql' THEN 'PGSQL' ELSE 'EXTERNAL' END AS character_data)
AS routine_body,
CAST(
CASE WHEN pg_has_role(p.proowner, 'USAGE') THEN p.prosrc ELSE null END
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index ae3002bb42..39c803fa00 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -52,7 +52,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
@@ -505,10 +505,10 @@ static const ObjectPropertyType ObjectProperty[] =
SubscriptionObjectIndexId,
SUBSCRIPTIONOID,
SUBSCRIPTIONNAME,
- Anum_pg_subscription_oid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_oid,
+ Anum_pg_sub_subname,
InvalidAttrNumber,
- Anum_pg_subscription_subowner,
+ Anum_pg_sub_subowner,
InvalidAttrNumber,
OBJECT_SUBSCRIPTION,
true
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 59f97bf3d0..900acb90a3 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -40,7 +40,7 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index 68d88ff499..c93e7037fc 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -20,7 +20,7 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/indexing.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
@@ -64,12 +64,12 @@ GetSubscription(Oid subid, bool missing_ok)
sub->dbid = subform->subdbid;
sub->name = pstrdup(NameStr(subform->subname));
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subconninfo,
+ Anum_pg_sub_subconn,
&isnull);
Assert(!isnull);
sub->conninfo = TextDatumGetCString(datum);
@@ -77,7 +77,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subslotname,
+ Anum_pg_sub_subslotname,
&isnull);
if (!isnull)
sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));
@@ -87,7 +87,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get synccommit */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subsynccommit,
+ Anum_pg_sub_subsynccommit,
&isnull);
Assert(!isnull);
sub->synccommit = TextDatumGetCString(datum);
@@ -95,7 +95,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get publications */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subpublications,
+ Anum_pg_sub_subpublications,
&isnull);
Assert(!isnull);
sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
@@ -121,7 +121,7 @@ CountDBSubscriptions(Oid dbid)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- Anum_pg_subscription_subdbid,
+ Anum_pg_sub_subdbid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
@@ -163,7 +163,7 @@ get_subscription_oid(const char *subname, bool missing_ok)
{
Oid oid;
- oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(subname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index f7800f01a6..20597dd1ff 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -477,7 +477,7 @@ SELECT
l.provider, l.label
FROM
pg_shseclabel l
- JOIN pg_subscription s ON l.classoid = s.tableoid AND l.objoid = s.oid
+ JOIN pg_sub s ON l.classoid = s.tableoid AND l.objoid = s.oid
UNION ALL
SELECT
l.objoid, l.classoid, 0::int4 AS objsubid,
@@ -803,19 +803,19 @@ CREATE VIEW pg_stat_wal_receiver AS
FROM pg_stat_get_wal_receiver() s
WHERE s.pid IS NOT NULL;
-CREATE VIEW pg_stat_subscription AS
+CREATE VIEW pg_stat_sub AS
SELECT
su.oid AS subid,
su.subname,
st.pid,
st.relid,
- st.received_lsn,
+ st.received_lsn received_location,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_lsn latest_end_location,
st.latest_end_time
- FROM pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL) st
+ FROM pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL) st
ON (st.subid = su.oid);
CREATE VIEW pg_stat_ssl AS
@@ -1062,9 +1062,9 @@ CREATE VIEW pg_replication_origin_status AS
REVOKE ALL ON pg_replication_origin_status FROM public;
-- All columns of pg_subscription except subconninfo are readable.
-REVOKE ALL ON pg_subscription FROM public;
-GRANT SELECT (subdbid, subname, subowner, subenabled, subslotname, subpublications)
- ON pg_subscription TO public;
+REVOKE ALL ON pg_sub FROM public;
+GRANT SELECT (subdbid, subname, subowner, subactive, subslotname, subpublications)
+ ON pg_sub TO public;
--
@@ -1114,7 +1114,7 @@ FROM pg_catalog.ts_parse(
) AS tt
WHERE tt.tokid = parse.tokid
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(regconfig,text) IS
'debug function for text search configuration';
@@ -1130,7 +1130,7 @@ RETURNS SETOF record AS
$$
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1);
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(text) IS
'debug function for current text search configuration';
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index d425ef935e..9429356e81 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -35,7 +35,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index a70e75a219..2b3bf4c888 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -38,7 +38,7 @@
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 5408edcfc2..911265ff6f 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -23,7 +23,7 @@
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
@@ -309,8 +309,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
Relation rel;
ObjectAddress myself;
Oid subid;
- bool nulls[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
Oid owner = GetUserId();
HeapTuple tup;
bool connect;
@@ -361,7 +361,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Check if name is used */
- subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(stmt->subname));
if (OidIsValid(subid))
{
@@ -392,23 +392,23 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
memset(nulls, false, sizeof(nulls));
subid = GetNewOidWithIndex(rel, SubscriptionObjectIndexId,
- Anum_pg_subscription_oid);
- values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
- values[Anum_pg_subscription_subname - 1] =
+ Anum_pg_sub_oid);
+ values[Anum_pg_sub_oid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
+ values[Anum_pg_sub_subname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
- values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
- values[Anum_pg_subscription_subenabled - 1] = BoolGetDatum(enabled);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subowner - 1] = ObjectIdGetDatum(owner);
+ values[Anum_pg_sub_subactive - 1] = BoolGetDatum(enabled);
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(conninfo);
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- values[Anum_pg_subscription_subsynccommit - 1] =
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(publications);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -623,9 +623,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
{
Relation rel;
ObjectAddress myself;
- bool nulls[Natts_pg_subscription];
- bool replaces[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ bool replaces[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
HeapTuple tup;
Oid subid;
bool update_tuple = false;
@@ -683,18 +683,18 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
"slot_name = NONE")));
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- replaces[Anum_pg_subscription_subslotname - 1] = true;
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ replaces[Anum_pg_sub_subslotname - 1] = true;
}
if (synchronous_commit)
{
- values[Anum_pg_subscription_subsynccommit - 1] =
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- replaces[Anum_pg_subscription_subsynccommit - 1] = true;
+ replaces[Anum_pg_sub_subsynccommit - 1] = true;
}
update_tuple = true;
@@ -716,9 +716,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot enable subscription that does not have a slot name")));
- values[Anum_pg_subscription_subenabled - 1] =
+ values[Anum_pg_sub_subactive - 1] =
BoolGetDatum(enabled);
- replaces[Anum_pg_subscription_subenabled - 1] = true;
+ replaces[Anum_pg_sub_subactive - 1] = true;
if (enabled)
ApplyLauncherWakeupAtCommit();
@@ -733,9 +733,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
/* Check the connection info string. */
walrcv_check_conninfo(stmt->conninfo);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(stmt->conninfo);
- replaces[Anum_pg_subscription_subconninfo - 1] = true;
+ replaces[Anum_pg_sub_subconn - 1] = true;
update_tuple = true;
break;
@@ -748,9 +748,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
NULL, NULL, NULL, ©_data,
NULL, &refresh);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(stmt->publication);
- replaces[Anum_pg_subscription_subpublications - 1] = true;
+ replaces[Anum_pg_sub_subpublications - 1] = true;
update_tuple = true;
@@ -884,19 +884,19 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
/* Get subname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subname, &isnull);
+ Anum_pg_sub_subname, &isnull);
Assert(!isnull);
subname = pstrdup(NameStr(*DatumGetName(datum)));
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subconninfo, &isnull);
+ Anum_pg_sub_subconn, &isnull);
Assert(!isnull);
conninfo = TextDatumGetCString(datum);
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subslotname, &isnull);
+ Anum_pg_sub_subslotname, &isnull);
if (!isnull)
slotname = pstrdup(NameStr(*DatumGetName(datum)));
else
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 4643af95fe..23b8df943b 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -22,7 +22,7 @@
#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "funcapi.h"
#include "libpq/pqsignal.h"
@@ -97,7 +97,7 @@ static volatile sig_atomic_t got_SIGHUP = false;
static bool on_commit_launcher_wakeup = false;
-Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
+Datum pg_stat_get_sub(PG_FUNCTION_ARGS);
/*
@@ -149,7 +149,7 @@ get_subscription_list(void)
sub->oid = subform->oid;
sub->dbid = subform->subdbid;
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->name = pstrdup(NameStr(subform->subname));
/* We don't fill fields we are not interested in. */
@@ -1084,7 +1084,7 @@ IsLogicalLauncher(void)
* Returns state of the subscriptions.
*/
Datum
-pg_stat_get_subscription(PG_FUNCTION_ARGS)
+pg_stat_get_sub(PG_FUNCTION_ARGS)
{
#define PG_STAT_GET_SUBSCRIPTION_COLS 8
Oid subid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index ced0d191c2..67cab841dd 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -29,7 +29,7 @@
#include "access/xlog_internal.h"
#include "catalog/catalog.h"
#include "catalog/namespace.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "commands/tablecmds.h"
#include "commands/trigger.h"
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 50f8912c13..9330d78c8a 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -59,7 +59,7 @@
#include "catalog/pg_rewrite.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
@@ -117,7 +117,7 @@ static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_
static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
-static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_subscription] = {Schema_pg_subscription};
+static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_sub] = {Schema_pg_sub};
/*
* Hash tables that index the relation cache
@@ -3648,8 +3648,8 @@ RelationCacheInitializePhase2(void)
Natts_pg_auth_members, Desc_pg_auth_members);
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
Natts_pg_shseclabel, Desc_pg_shseclabel);
- formrdesc("pg_subscription", SubscriptionRelation_Rowtype_Id, true,
- Natts_pg_subscription, Desc_pg_subscription);
+ formrdesc("pg_sub", SubscriptionRelation_Rowtype_Id, true,
+ Natts_pg_sub, Desc_pg_subscription);
#define NUM_CRITICAL_SHARED_RELS 5 /* fix if you change list above */
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index d69c0ff813..d021d37fba 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -63,7 +63,7 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
@@ -776,8 +776,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionNameIndexId,
2,
{
- Anum_pg_subscription_subdbid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_subdbid,
+ Anum_pg_sub_subname,
0,
0
},
@@ -787,7 +787,7 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionObjectIndexId,
1,
{
- Anum_pg_subscription_oid,
+ Anum_pg_sub_oid,
0,
0,
0
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 08658c8e86..cca150a39c 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4117,7 +4117,7 @@ getSubscriptions(Archive *fout)
int n;
res = ExecuteSqlQuery(fout,
- "SELECT count(*) FROM pg_subscription "
+ "SELECT count(*) FROM pg_sub "
"WHERE subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
PGRES_TUPLES_OK);
@@ -4136,9 +4136,9 @@ getSubscriptions(Archive *fout)
appendPQExpBuffer(query,
"SELECT s.tableoid, s.oid, s.subname,"
"(%s s.subowner) AS rolname, "
- " s.subconninfo, s.subslotname, s.subsynccommit, "
+ " s.subconn, s.subslotname, s.subsynccommit, "
" s.subpublications "
- "FROM pg_subscription s "
+ "FROM pg_sub s "
"WHERE s.subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
username_subquery);
@@ -4150,7 +4150,7 @@ getSubscriptions(Archive *fout)
i_oid = PQfnumber(res, "oid");
i_subname = PQfnumber(res, "subname");
i_rolname = PQfnumber(res, "rolname");
- i_subconninfo = PQfnumber(res, "subconninfo");
+ i_subconninfo = PQfnumber(res, "subconn");
i_subslotname = PQfnumber(res, "subslotname");
i_subsynccommit = PQfnumber(res, "subsynccommit");
i_subpublications = PQfnumber(res, "subpublications");
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index ef4445b017..8d4c8d8eb5 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -357,10 +357,10 @@ DECLARE_UNIQUE_INDEX(pg_publication_rel_oid_index, 6112, on pg_publication_rel u
DECLARE_UNIQUE_INDEX(pg_publication_rel_prrelid_prpubid_index, 6113, on pg_publication_rel using btree(prrelid oid_ops, prpubid oid_ops));
#define PublicationRelPrrelidPrpubidIndexId 6113
-DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_sub using btree(oid oid_ops));
#define SubscriptionObjectIndexId 6114
-DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_sub using btree(subdbid oid_ops, subname name_ops));
#define SubscriptionNameIndexId 6115
DECLARE_UNIQUE_INDEX(pg_subscription_rel_srrelid_srsubid_index, 6117, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
diff --git a/src/include/catalog/pg_language.dat b/src/include/catalog/pg_language.dat
index 02dde38a1c..5c82c1b545 100644
--- a/src/include/catalog/pg_language.dat
+++ b/src/include/catalog/pg_language.dat
@@ -20,6 +20,6 @@
lanname => 'c', lanvalidator => 'fmgr_c_validator' },
{ oid => '14', oid_symbol => 'SQLlanguageId',
descr => 'SQL-language functions',
- lanname => 'sql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
+ lanname => 'pgsql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
]
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index ac8f64b219..27a80a6a5f 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2281,7 +2281,7 @@
proname => 'justify_days', prorettype => 'interval',
proargtypes => 'interval', prosrc => 'interval_justify_days' },
{ oid => '1176', descr => 'convert date and time to timestamp with time zone',
- proname => 'timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'date time',
prosrc => 'select cast(($1 + $2) as timestamp with time zone)' },
{ oid => '1178', descr => 'convert timestamp with time zone to date',
@@ -2334,16 +2334,16 @@
prosrc => 'interval_scale' },
{ oid => '1215', descr => 'get description for object id and catalog name',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0' },
{ oid => '1216', descr => 'get description for table column',
- proname => 'col_description', prolang => 'sql', procost => '100',
+ proname => 'col_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'pg_catalog.pg_class\'::pg_catalog.regclass and objsubid = $2' },
{ oid => '1993',
descr => 'get description for object id and shared catalog name',
- proname => 'shobj_description', prolang => 'sql', procost => '100',
+ proname => 'shobj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP)' },
@@ -2519,13 +2519,13 @@
prosrc => 'hashtidextended' },
{ oid => '1296',
- proname => 'timedate_pl', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'timedate_pl', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'time date', prosrc => 'select ($2 + $1)' },
{ oid => '1297',
proname => 'datetimetz_pl', prorettype => 'timestamptz',
proargtypes => 'date timetz', prosrc => 'datetimetz_timestamptz' },
{ oid => '1298',
- proname => 'timetzdate_pl', prolang => 'sql', prorettype => 'timestamptz',
+ proname => 'timetzdate_pl', prolang => 'pgsql', prorettype => 'timestamptz',
proargtypes => 'timetz date', prosrc => 'select ($2 + $1)' },
{ oid => '1299', descr => 'current transaction time',
proname => 'now', provolatile => 's', prorettype => 'timestamptz',
@@ -2567,17 +2567,17 @@
proargtypes => 'timestamptz timestamptz timestamptz timestamptz',
prosrc => 'overlaps_timestamp' },
{ oid => '1305', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1306', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz timestamptz timestamptz interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1307', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz timestamptz',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2586,15 +2586,15 @@
proname => 'overlaps', proisstrict => 'f', prorettype => 'bool',
proargtypes => 'time time time time', prosrc => 'overlaps_time' },
{ oid => '1309', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1310', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time time time interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1311', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time time',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2675,7 +2675,7 @@
# This form of obj_description is now deprecated, since it will fail if
# OIDs are not unique across system catalogs. Use the other form instead.
{ oid => '1348', descr => 'deprecated, use two-argument form instead',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and objsubid = 0' },
@@ -2759,7 +2759,7 @@
prosrc => 'textlen' },
{ oid => '1384', descr => 'extract field from date',
- proname => 'date_part', prolang => 'sql', prorettype => 'float8',
+ proname => 'date_part', prolang => 'pgsql', prorettype => 'float8',
proargtypes => 'text date',
prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time zone))' },
{ oid => '1385', descr => 'extract field from time',
@@ -2767,7 +2767,7 @@
prosrc => 'time_part' },
{ oid => '1386',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp with time zone), $1)' },
@@ -2882,7 +2882,7 @@
proname => 'box_div', prorettype => 'box', proargtypes => 'box point',
prosrc => 'box_div' },
{ oid => '1426',
- proname => 'path_contain_pt', prolang => 'sql', prorettype => 'bool',
+ proname => 'path_contain_pt', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'path point', prosrc => 'select pg_catalog.on_ppath($2, $1)' },
{ oid => '1428',
proname => 'poly_contain_pt', prorettype => 'bool',
@@ -3142,7 +3142,7 @@
proname => 'center', prorettype => 'point', proargtypes => 'circle',
prosrc => 'circle_center' },
{ oid => '1544', descr => 'convert circle to 12-vertex polygon',
- proname => 'polygon', prolang => 'sql', prorettype => 'polygon',
+ proname => 'polygon', prolang => 'pgsql', prorettype => 'polygon',
proargtypes => 'circle', prosrc => 'select pg_catalog.polygon(12, $1)' },
{ oid => '1545', descr => 'number of points',
proname => 'npoints', prorettype => 'int4', proargtypes => 'path',
@@ -3438,11 +3438,11 @@
proname => 'translate', prorettype => 'text', proargtypes => 'text text text',
prosrc => 'translate' },
{ oid => '879', descr => 'left-pad string to length',
- proname => 'lpad', prolang => 'sql', prorettype => 'text',
+ proname => 'lpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.lpad($1, $2, \' \')' },
{ oid => '880', descr => 'right-pad string to length',
- proname => 'rpad', prolang => 'sql', prorettype => 'text',
+ proname => 'rpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.rpad($1, $2, \' \')' },
{ oid => '881', descr => 'trim spaces from left end of string',
@@ -4033,7 +4033,7 @@
proname => 'inetpl', prorettype => 'inet', proargtypes => 'inet int8',
prosrc => 'inetpl' },
{ oid => '2631',
- proname => 'int8pl_inet', prolang => 'sql', prorettype => 'inet',
+ proname => 'int8pl_inet', prolang => 'pgsql', prorettype => 'inet',
proargtypes => 'int8 inet', prosrc => 'select $2 + $1' },
{ oid => '2632',
proname => 'inetmi_int8', prorettype => 'inet', proargtypes => 'inet int8',
@@ -4165,13 +4165,13 @@
proname => 'round', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_round' },
{ oid => '1708', descr => 'value rounded to \'scale\' of zero',
- proname => 'round', prolang => 'sql', prorettype => 'numeric',
+ proname => 'round', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.round($1,0)' },
{ oid => '1709', descr => 'value truncated to \'scale\'',
proname => 'trunc', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_trunc' },
{ oid => '1710', descr => 'value truncated to \'scale\' of zero',
- proname => 'trunc', prolang => 'sql', prorettype => 'numeric',
+ proname => 'trunc', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.trunc($1,0)' },
{ oid => '1711', descr => 'nearest integer >= value',
proname => 'ceil', prorettype => 'numeric', proargtypes => 'numeric',
@@ -4258,10 +4258,10 @@
proname => 'numeric', prorettype => 'numeric', proargtypes => 'int4',
prosrc => 'int4_numeric' },
{ oid => '1741', descr => 'base 10 logarithm',
- proname => 'log', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1481', descr => 'base 10 logarithm',
- proname => 'log10', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log10', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1742', descr => 'convert float4 to numeric',
proname => 'numeric', prorettype => 'numeric', proargtypes => 'float4',
@@ -4394,7 +4394,7 @@
proname => 'quote_literal', prorettype => 'text', proargtypes => 'text',
prosrc => 'quote_literal' },
{ oid => '1285', descr => 'quote a data value for usage in a querystring',
- proname => 'quote_literal', prolang => 'sql', provolatile => 's',
+ proname => 'quote_literal', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_literal($1::pg_catalog.text)' },
{ oid => '1289',
@@ -4403,7 +4403,7 @@
proargtypes => 'text', prosrc => 'quote_nullable' },
{ oid => '1290',
descr => 'quote a possibly-null data value for usage in a querystring',
- proname => 'quote_nullable', prolang => 'sql', proisstrict => 'f',
+ proname => 'quote_nullable', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_nullable($1::pg_catalog.text)' },
@@ -4442,13 +4442,13 @@
prorettype => 'text', proargtypes => 'text', prosrc => 'text_format_nv' },
{ oid => '1810', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bytea', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1811', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'text', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1812', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bit', prosrc => 'select pg_catalog.length($1)' },
# Selectivity estimators for LIKE and related operators
@@ -4767,7 +4767,7 @@
prosrc => 'to_ascii_encname' },
{ oid => '1848',
- proname => 'interval_pl_time', prolang => 'sql', prorettype => 'time',
+ proname => 'interval_pl_time', prolang => 'pgsql', prorettype => 'time',
proargtypes => 'interval time', prosrc => 'select $2 + $1' },
{ oid => '1850',
@@ -5178,12 +5178,12 @@
proargnames => '{pid,status,receive_start_lsn,receive_start_tli,received_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
prosrc => 'pg_stat_get_wal_receiver' },
{ oid => '6118', descr => 'statistics: information about subscription',
- proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
+ proname => 'pg_stat_get_sub', proisstrict => 'f', provolatile => 's',
proparallel => 'r', prorettype => 'record', proargtypes => 'oid',
proallargtypes => '{oid,oid,oid,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}',
proargmodes => '{i,o,o,o,o,o,o,o,o}',
proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}',
- prosrc => 'pg_stat_get_subscription' },
+ prosrc => 'pg_stat_get_sub' },
{ oid => '2026', descr => 'statistics: current backend PID',
proname => 'pg_backend_pid', provolatile => 's', proparallel => 'r',
prorettype => 'int4', proargtypes => '', prosrc => 'pg_backend_pid' },
@@ -5579,11 +5579,11 @@
proargtypes => 'timetz int4', prosrc => 'timetz_scale' },
{ oid => '2003',
- proname => 'textanycat', prolang => 'sql', provolatile => 's',
+ proname => 'textanycat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'text anynonarray',
prosrc => 'select $1 || $2::pg_catalog.text' },
{ oid => '2004',
- proname => 'anytextcat', prolang => 'sql', provolatile => 's',
+ proname => 'anytextcat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anynonarray text',
prosrc => 'select $1::pg_catalog.text || $2' },
@@ -5683,15 +5683,15 @@
proargtypes => 'timestamp timestamp timestamp timestamp',
prosrc => 'overlaps_timestamp' },
{ oid => '2042', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '2043', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp timestamp timestamp interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '2044', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp timestamp',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
{ oid => '2045', descr => 'less-equal-greater',
@@ -5757,7 +5757,7 @@
proargtypes => 'timestamp timestamp', prosrc => 'timestamp_age' },
{ oid => '2059',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamp',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp without time zone), $1)' },
@@ -5778,7 +5778,7 @@
proname => 'substring', prorettype => 'text', proargtypes => 'text text',
prosrc => 'textregexsubstr' },
{ oid => '2074', descr => 'extract text matching SQL regular expression',
- proname => 'substring', prolang => 'sql', prorettype => 'text',
+ proname => 'substring', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text text text',
prosrc => 'select pg_catalog.substring($1, pg_catalog.similar_to_escape($2, $3))' },
@@ -6117,11 +6117,11 @@
proname => 'pg_sleep', provolatile => 'v', prorettype => 'void',
proargtypes => 'float8', prosrc => 'pg_sleep' },
{ oid => '3935', descr => 'sleep for the specified interval',
- proname => 'pg_sleep_for', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_for', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'interval',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from pg_catalog.clock_timestamp() operator(pg_catalog.+) $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '3936', descr => 'sleep until the specified time',
- proname => 'pg_sleep_until', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_until', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '315', descr => 'Is JIT compilation available in this session?',
@@ -6922,7 +6922,7 @@
proargtypes => 'name', prosrc => 'pg_database_size_name' },
{ oid => '2325',
descr => 'disk space usage for the main fork of the specified table or index',
- proname => 'pg_relation_size', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_relation_size', prolang => 'pgsql', provolatile => 'v',
prorettype => 'int8', proargtypes => 'regclass',
prosrc => 'select pg_catalog.pg_relation_size($1, \'main\')' },
{ oid => '2332',
@@ -7760,21 +7760,21 @@
# formerly-missing interval + datetime operators
{ oid => '2546',
- proname => 'interval_pl_date', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'interval_pl_date', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'interval date', prosrc => 'select $2 + $1' },
{ oid => '2547',
- proname => 'interval_pl_timetz', prolang => 'sql', prorettype => 'timetz',
+ proname => 'interval_pl_timetz', prolang => 'pgsql', prorettype => 'timetz',
proargtypes => 'interval timetz', prosrc => 'select $2 + $1' },
{ oid => '2548',
- proname => 'interval_pl_timestamp', prolang => 'sql',
+ proname => 'interval_pl_timestamp', prolang => 'pgsql',
prorettype => 'timestamp', proargtypes => 'interval timestamp',
prosrc => 'select $2 + $1' },
{ oid => '2549',
- proname => 'interval_pl_timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'interval_pl_timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'interval timestamptz',
prosrc => 'select $2 + $1' },
{ oid => '2550',
- proname => 'integer_pl_date', prolang => 'sql', prorettype => 'date',
+ proname => 'integer_pl_date', prolang => 'pgsql', prorettype => 'date',
proargtypes => 'int4 date', prosrc => 'select $2 + $1' },
{ oid => '2556', descr => 'get OIDs of databases in a tablespace',
@@ -8163,7 +8163,7 @@
proname => 'xpath', prorettype => '_xml', proargtypes => 'text xml _text',
prosrc => 'xpath' },
{ oid => '2932', descr => 'evaluate XPath expression',
- proname => 'xpath', prolang => 'sql', prorettype => '_xml',
+ proname => 'xpath', prolang => 'pgsql', prorettype => '_xml',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath($1, $2, \'{}\'::pg_catalog.text[])' },
@@ -8176,7 +8176,7 @@
proname => 'xpath_exists', prorettype => 'bool',
proargtypes => 'text xml _text', prosrc => 'xpath_exists' },
{ oid => '3050', descr => 'test XML value against XPath expression',
- proname => 'xpath_exists', prolang => 'sql', prorettype => 'bool',
+ proname => 'xpath_exists', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '3051', descr => 'determine if a string is well formed XML',
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_sub.h
similarity index 90%
rename from src/include/catalog/pg_subscription.h
rename to src/include/catalog/pg_sub.h
index 3cb13d897e..6628814833 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_sub.h
@@ -18,7 +18,7 @@
#define PG_SUBSCRIPTION_H
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_d.h"
+#include "catalog/pg_sub_d.h"
#include "nodes/pg_list.h"
@@ -36,7 +36,7 @@
*
* NOTE: When adding a column, also update system_views.sql.
*/
-CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
+CATALOG(pg_sub,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
@@ -45,12 +45,12 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
Oid subowner; /* Owner of the subscription */
- bool subenabled; /* True if the subscription is enabled (the
+ bool subactive; /* True if the subscription is enabled (the
* worker should be running) */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* Connection string to the publisher */
- text subconninfo BKI_FORCE_NOT_NULL;
+ text subconn BKI_FORCE_NOT_NULL;
/* Slot name on publisher */
NameData subslotname;
diff --git a/src/include/catalog/toasting.h b/src/include/catalog/toasting.h
index cc5dfed0bf..40a0c901cd 100644
--- a/src/include/catalog/toasting.h
+++ b/src/include/catalog/toasting.h
@@ -98,7 +98,7 @@ DECLARE_TOAST(pg_shdescription, 2846, 2847);
DECLARE_TOAST(pg_shseclabel, 4060, 4061);
#define PgShseclabelToastTable 4060
#define PgShseclabelToastIndex 4061
-DECLARE_TOAST(pg_subscription, 4183, 4184);
+DECLARE_TOAST(pg_sub, 4183, 4184);
#define PgSubscriptionToastTable 4183
#define PgSubscriptionToastIndex 4184
DECLARE_TOAST(pg_tablespace, 4185, 4186);
diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h
index 05f4936419..d1cf8906a7 100644
--- a/src/include/replication/worker_internal.h
+++ b/src/include/replication/worker_internal.h
@@ -15,7 +15,7 @@
#include <signal.h>
#include "access/xlogdefs.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
On 06.04.2020 19:40, Anastasia Lubennikova wrote:
On 06.04.2020 16:49, Anastasia Lubennikova wrote:
New version of the patch is attached. I fixed several issues in the
check_for_changed_signatures().Now it passes check without "test_rename_catalog_objects" and fails
(generates script) with it. Test script pg_upgrade_ACL_test.sh
demonstrates this.The only known issue left is the usage of pg_identify_object(),
though I don't see a problem here with object types that this patch
involves.
As I updated the code, I will leave this patch in Need Review.One more fix for free_acl_infos().
Thanks to cfbot.
One more update.
In this version I rebased test patches,� added some more comments, fixed
memory allocation issue and also removed code that handles ACLs on
languages. They require a lot of specific handling, while I doubt that
their signatures, which consist of language name only, are subject to
change in any future versions.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v9.patchtext/x-patch; charset=UTF-8; name=pg_upgrade_ACL_check_v9.patchDownload
commit c7ce324b4a213184c9b5fec18055921fc846ccad
Author: anastasia <a.lubennikova@postgrespro.ru>
Date: Mon Jun 8 18:34:14 2020 +0300
pg_upgrade_ACL_check_v9.patch
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 00aef855dc..94e8528a3a 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -142,6 +143,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -161,6 +164,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -443,6 +447,223 @@ check_databases_are_compatible(void)
}
}
+/*
+ * Find the location of the last dot, return NULL if not found.
+ */
+static char *
+last_dot_location(const char *identity)
+{
+ const char *p,
+ *ret = NULL;
+
+ for (p = identity; *p; p++)
+ if (*p == '.')
+ ret = p;
+ return unconstify(char *, ret);
+}
+
+/*
+ * check_for_changed_signatures()
+ *
+ * Check that the old cluster doesn't have non-default ACL's for system objects
+ * (relations, attributes, functions and procedures) which have different
+ * signatures in the new cluster. Otherwise generate revoke_objects.sql.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ char subquery[QUERY_ALLOC];
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ prep_status("Checking for system objects with non-default ACL");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+ /*
+ * The old cluster doesn't have system objects with non-default ACL so
+ * quickly exit.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "revoke_objects.sql");
+
+ snprintf(subquery, sizeof(subquery),
+ /* Get system relations which created in pg_catalog */
+ "SELECT 'pg_class'::regclass classid, oid objid, 0 objsubid "
+ "FROM pg_catalog.pg_class "
+ "WHERE relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system relations attributes which created in pg_catalog */
+ "SELECT 'pg_class'::regclass, att.attrelid, att.attnum "
+ "FROM pg_catalog.pg_class rel "
+ "INNER JOIN pg_catalog.pg_attribute att ON rel.oid = att.attrelid "
+ "WHERE rel.relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system functions and procedure which created in pg_catalog */
+ "SELECT 'pg_proc'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_proc "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace ");
+
+ conn = connectToServer(&new_cluster, "template1");
+ res = executeQueryOrDie(conn,
+ "SELECT ident.type, ident.identity "
+ "FROM (%s) obj, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " obj.classid, obj.objid, obj.objsubid) ident "
+ /*
+ * Don't rely on database collation, since we use strcmp
+ * comparison to find non-default ACLs.
+ */
+ "ORDER BY ident.identity COLLATE \"C\";", subquery);
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ * For every database check system objects with non-default ACL.
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool report = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(aclinfo->obj_ident,
+ PQgetvalue(res, objnum, i_obj_ident));
+
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ {
+ report = true;
+ break;
+ }
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ objnum++;
+ break;
+ }
+ else
+ objnum++;
+ }
+
+ if (report)
+ {
+ found_changed = true;
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n",
+ output_path, strerror(errno));
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+ /* Handle columns separately */
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ {
+ char *pdot = last_dot_location(aclinfo->obj_ident);
+ PQExpBufferData ident_buf;
+
+ if (pdot == NULL || *(pdot + 1) == '\0')
+ pg_fatal("invalid column identity \"%s\"",
+ aclinfo->obj_ident);
+
+ initPQExpBuffer(&ident_buf);
+ appendBinaryPQExpBuffer(&ident_buf, aclinfo->obj_ident,
+ pdot - aclinfo->obj_ident);
+
+ fprintf(script, "REVOKE ALL (%s) ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ pdot + 1, ident_buf.data,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ termPQExpBuffer(&ident_buf);
+ }
+ /*
+ * For relations except sequences we don't need to specify
+ * the object type.
+ */
+ else if (aclinfo->is_relation &&
+ strcmp(aclinfo->obj_type, "sequence") != 0)
+ fprintf(script, "REVOKE ALL ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ /* Other object types */
+ else
+ fprintf(script, "REVOKE ALL ON %s %s FROM %s;\n",
+ aclinfo->obj_type,
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* create_script_for_cluster_analyze()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 7e524ea192..2fad020567 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,114 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Fill AclInfo array with information about system objects that
+ * have non-default ACL.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos;
+ AclInfo *curr;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_rolname,
+ i_is_relation;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get relations, attributes, functions and procedures. Some system
+ * objects like views are not pinned, but these type of objects are
+ * created in pg_catalog schema.
+ */
+ "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, "
+ " CASE WHEN shd.classid = 'pg_class'::regclass THEN true "
+ " ELSE false "
+ " END is_relation "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj "
+ /* 'a' is for SHARED_DEPENDENCY_ACL */
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid IN ('pg_proc'::regclass, 'pg_class'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ * Don't rely on database collation, since we use strcmp
+ * comparison below.
+ */
+ "ORDER BY obj.identity COLLATE \"C\";", dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_rolname = PQfnumber(res, "rolename");
+ i_is_relation = PQfnumber(res, "is_relation");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBuffer roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+ curr->is_relation = PQgetvalue(res, aclnum, i_is_relation)[0] == 't';
+
+ roles_buf = createPQExpBuffer();
+ initPQExpBuffer(roles_buf);
+
+ /*
+ * For each object gather string of role names mentioned in ACL
+ * in a format convenient for further use in REVOKE statement.
+ */
+ while (aclnum < PQntuples(res) &&
+ strcmp(curr->obj_ident, PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf->len != 0)
+ appendPQExpBufferChar(roles_buf, ',');
+
+ appendPQExpBufferStr(roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+
+ curr->role_names = pg_strdup(roles_buf->data);
+ destroyPQExpBuffer(roles_buf);
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -384,6 +494,9 @@ get_db_infos(ClusterInfo *cluster)
dbinfos[tupnum].db_ctype = pg_strdup(PQgetvalue(res, tupnum, i_datctype));
snprintf(dbinfos[tupnum].db_tablespace, sizeof(dbinfos[tupnum].db_tablespace), "%s",
PQgetvalue(res, tupnum, i_spclocation));
+
+ /* initialize clean array */
+ dbinfos[tupnum].non_def_acl_arr.nacls = 0;
}
PQclear(res);
@@ -595,6 +708,8 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+ if (&db_arr->dbs[dbnum].non_def_acl_arr.nacls > 0)
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +735,21 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+ pg_free(acl_arr->aclinfos);
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 8b90cefbe0..33bbe2d233 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -147,6 +147,26 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Information about database object needed to check
+ * if its signature has changed between versions
+ * and generate REVOKE statement if necessary.
+ */
+typedef struct
+{
+ char *obj_type; /* object type */
+ char *obj_ident; /* complete object identity */
+ bool is_relation; /* if the object is relation */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -183,6 +203,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -390,6 +412,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
test_rename_catalog_objects_v9text/plain; charset=UTF-8; name=test_rename_catalog_objects_v9Download
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 9499bb33e5..4fdd367a6f 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -67,7 +67,7 @@ CATALOG_HEADERS := \
pg_foreign_table.h pg_policy.h pg_replication_origin.h \
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
- pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
+ pg_sequence.h pg_publication.h pg_publication_rel.h pg_sub.h \
pg_subscription_rel.h
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index cb2c4972ad..7c4247e2c9 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -50,7 +50,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 7d6acaed92..e251b410e6 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -37,7 +37,7 @@
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/toasting.h"
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 5565e6fc19..38ac1f8c53 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 3e07fb107e..cba7e55ce0 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -42,7 +42,7 @@ SET search_path TO information_schema;
/* Expand any 1-D array into a set with integers 1..N */
CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
RETURNS SETOF RECORD
- LANGUAGE sql STRICT IMMUTABLE PARALLEL SAFE
+ LANGUAGE pgsql STRICT IMMUTABLE PARALLEL SAFE
AS 'select $1[s], s - pg_catalog.array_lower($1,1) + 1
from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
pg_catalog.array_upper($1,1),
@@ -51,7 +51,7 @@ CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
/* Given an index's OID and an underlying-table column number, return the
* column's position in the index (NULL if not there) */
CREATE FUNCTION _pg_index_position(oid, smallint) RETURNS int
- LANGUAGE sql STRICT STABLE
+ LANGUAGE pgsql STRICT STABLE
AS $$
SELECT (ss.a).n FROM
(SELECT information_schema._pg_expandarray(indkey) AS a
@@ -60,7 +60,7 @@ SELECT (ss.a).n FROM
$$;
CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -68,7 +68,7 @@ CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
$$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typbasetype ELSE $1.atttypid END$$;
CREATE FUNCTION _pg_truetypmod(pg_attribute, pg_type) RETURNS int4
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -78,7 +78,7 @@ $$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typtypmod ELSE $1.atttypmod END$$;
-- these functions encapsulate knowledge about the encoding of typmod:
CREATE FUNCTION _pg_char_max_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -94,7 +94,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_char_octet_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -110,7 +110,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -131,7 +131,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision_radix(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -143,7 +143,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_scale(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -159,7 +159,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_datetime_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -175,7 +175,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_interval_type(typid oid, mod int4) RETURNS text
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -1477,7 +1477,7 @@ CREATE VIEW routines AS
CAST(null AS cardinal_number) AS maximum_cardinality,
CAST(CASE WHEN p.prokind <> 'p' THEN 0 END AS sql_identifier) AS dtd_identifier,
- CAST(CASE WHEN l.lanname = 'sql' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
+ CAST(CASE WHEN l.lanname = 'pgsql' THEN 'PGSQL' ELSE 'EXTERNAL' END AS character_data)
AS routine_body,
CAST(
CASE WHEN pg_has_role(p.proowner, 'USAGE') THEN p.prosrc ELSE null END
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 84463f76fc..cf2fb78187 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -52,7 +52,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
@@ -506,10 +506,10 @@ static const ObjectPropertyType ObjectProperty[] =
SubscriptionObjectIndexId,
SUBSCRIPTIONOID,
SUBSCRIPTIONNAME,
- Anum_pg_subscription_oid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_oid,
+ Anum_pg_sub_subname,
InvalidAttrNumber,
- Anum_pg_subscription_subowner,
+ Anum_pg_sub_subowner,
InvalidAttrNumber,
OBJECT_SUBSCRIPTION,
true
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index f776e821b3..a2e4b61bc0 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -40,7 +40,7 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index cb15731115..092e059c73 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -20,7 +20,7 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/indexing.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
@@ -64,12 +64,12 @@ GetSubscription(Oid subid, bool missing_ok)
sub->dbid = subform->subdbid;
sub->name = pstrdup(NameStr(subform->subname));
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subconninfo,
+ Anum_pg_sub_subconn,
&isnull);
Assert(!isnull);
sub->conninfo = TextDatumGetCString(datum);
@@ -77,7 +77,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subslotname,
+ Anum_pg_sub_subslotname,
&isnull);
if (!isnull)
sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));
@@ -87,7 +87,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get synccommit */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subsynccommit,
+ Anum_pg_sub_subsynccommit,
&isnull);
Assert(!isnull);
sub->synccommit = TextDatumGetCString(datum);
@@ -95,7 +95,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get publications */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subpublications,
+ Anum_pg_sub_subpublications,
&isnull);
Assert(!isnull);
sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
@@ -121,7 +121,7 @@ CountDBSubscriptions(Oid dbid)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- Anum_pg_subscription_subdbid,
+ Anum_pg_sub_subdbid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
@@ -163,7 +163,7 @@ get_subscription_oid(const char *subname, bool missing_ok)
{
Oid oid;
- oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(subname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index 56420bbc9d..2c37eabff4 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -478,7 +478,7 @@ SELECT
l.provider, l.label
FROM
pg_shseclabel l
- JOIN pg_subscription s ON l.classoid = s.tableoid AND l.objoid = s.oid
+ JOIN pg_sub s ON l.classoid = s.tableoid AND l.objoid = s.oid
UNION ALL
SELECT
l.objoid, l.classoid, 0::int4 AS objsubid,
@@ -826,19 +826,19 @@ CREATE VIEW pg_stat_wal_receiver AS
FROM pg_stat_get_wal_receiver() s
WHERE s.pid IS NOT NULL;
-CREATE VIEW pg_stat_subscription AS
+CREATE VIEW pg_stat_sub AS
SELECT
su.oid AS subid,
su.subname,
st.pid,
st.relid,
- st.received_lsn,
+ st.received_lsn received_location,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_lsn latest_end_location,
st.latest_end_time
- FROM pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL) st
+ FROM pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL) st
ON (st.subid = su.oid);
CREATE VIEW pg_stat_ssl AS
@@ -1124,9 +1124,9 @@ CREATE VIEW pg_replication_origin_status AS
REVOKE ALL ON pg_replication_origin_status FROM public;
-- All columns of pg_subscription except subconninfo are readable.
-REVOKE ALL ON pg_subscription FROM public;
-GRANT SELECT (subdbid, subname, subowner, subenabled, subslotname, subpublications)
- ON pg_subscription TO public;
+REVOKE ALL ON pg_sub FROM public;
+GRANT SELECT (subdbid, subname, subowner, subactive, subslotname, subpublications)
+ ON pg_sub TO public;
--
@@ -1176,7 +1176,7 @@ FROM pg_catalog.ts_parse(
) AS tt
WHERE tt.tokid = parse.tokid
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(regconfig,text) IS
'debug function for text search configuration';
@@ -1192,7 +1192,7 @@ RETURNS SETOF record AS
$$
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1);
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(text) IS
'debug function for current text search configuration';
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index b11ebf0f61..27d4f6dfcc 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -35,7 +35,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index f27c3fe8c1..b87df4d80d 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -38,7 +38,7 @@
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 9ebb026187..088c1f357e 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -23,7 +23,7 @@
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
@@ -310,8 +310,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
Relation rel;
ObjectAddress myself;
Oid subid;
- bool nulls[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
Oid owner = GetUserId();
HeapTuple tup;
bool connect;
@@ -362,7 +362,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Check if name is used */
- subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(stmt->subname));
if (OidIsValid(subid))
{
@@ -393,23 +393,23 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
memset(nulls, false, sizeof(nulls));
subid = GetNewOidWithIndex(rel, SubscriptionObjectIndexId,
- Anum_pg_subscription_oid);
- values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
- values[Anum_pg_subscription_subname - 1] =
+ Anum_pg_sub_oid);
+ values[Anum_pg_sub_oid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
+ values[Anum_pg_sub_subname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
- values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
- values[Anum_pg_subscription_subenabled - 1] = BoolGetDatum(enabled);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subowner - 1] = ObjectIdGetDatum(owner);
+ values[Anum_pg_sub_subactive - 1] = BoolGetDatum(enabled);
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(conninfo);
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- values[Anum_pg_subscription_subsynccommit - 1] =
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(publications);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -623,9 +623,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
{
Relation rel;
ObjectAddress myself;
- bool nulls[Natts_pg_subscription];
- bool replaces[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ bool replaces[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
HeapTuple tup;
Oid subid;
bool update_tuple = false;
@@ -683,18 +683,18 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
"slot_name = NONE")));
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- replaces[Anum_pg_subscription_subslotname - 1] = true;
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ replaces[Anum_pg_sub_subslotname - 1] = true;
}
if (synchronous_commit)
{
- values[Anum_pg_subscription_subsynccommit - 1] =
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- replaces[Anum_pg_subscription_subsynccommit - 1] = true;
+ replaces[Anum_pg_sub_subsynccommit - 1] = true;
}
update_tuple = true;
@@ -716,9 +716,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot enable subscription that does not have a slot name")));
- values[Anum_pg_subscription_subenabled - 1] =
+ values[Anum_pg_sub_subactive - 1] =
BoolGetDatum(enabled);
- replaces[Anum_pg_subscription_subenabled - 1] = true;
+ replaces[Anum_pg_sub_subactive - 1] = true;
if (enabled)
ApplyLauncherWakeupAtCommit();
@@ -733,9 +733,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
/* Check the connection info string. */
walrcv_check_conninfo(stmt->conninfo);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(stmt->conninfo);
- replaces[Anum_pg_subscription_subconninfo - 1] = true;
+ replaces[Anum_pg_sub_subconn - 1] = true;
update_tuple = true;
break;
@@ -748,9 +748,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
NULL, NULL, NULL, ©_data,
NULL, &refresh);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(stmt->publication);
- replaces[Anum_pg_subscription_subpublications - 1] = true;
+ replaces[Anum_pg_sub_subpublications - 1] = true;
update_tuple = true;
@@ -884,19 +884,19 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
/* Get subname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subname, &isnull);
+ Anum_pg_sub_subname, &isnull);
Assert(!isnull);
subname = pstrdup(NameStr(*DatumGetName(datum)));
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subconninfo, &isnull);
+ Anum_pg_sub_subconn, &isnull);
Assert(!isnull);
conninfo = TextDatumGetCString(datum);
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subslotname, &isnull);
+ Anum_pg_sub_subslotname, &isnull);
if (!isnull)
slotname = pstrdup(NameStr(*DatumGetName(datum)));
else
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index aec885e987..375f7a598d 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -22,7 +22,7 @@
#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "funcapi.h"
#include "libpq/pqsignal.h"
@@ -95,7 +95,7 @@ static void logicalrep_worker_cleanup(LogicalRepWorker *worker);
static bool on_commit_launcher_wakeup = false;
-Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
+Datum pg_stat_get_sub(PG_FUNCTION_ARGS);
/*
@@ -147,7 +147,7 @@ get_subscription_list(void)
sub->oid = subform->oid;
sub->dbid = subform->subdbid;
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->name = pstrdup(NameStr(subform->subname));
/* We don't fill fields we are not interested in. */
@@ -1068,7 +1068,7 @@ IsLogicalLauncher(void)
* Returns state of the subscriptions.
*/
Datum
-pg_stat_get_subscription(PG_FUNCTION_ARGS)
+pg_stat_get_sub(PG_FUNCTION_ARGS)
{
#define PG_STAT_GET_SUBSCRIPTION_COLS 8
Oid subid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index a752a1224d..4e35ad2aec 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -31,7 +31,7 @@
#include "catalog/namespace.h"
#include "catalog/partition.h"
#include "catalog/pg_inherits.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "commands/tablecmds.h"
#include "commands/trigger.h"
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 0b9eb00d2d..f54ac3eeab 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -59,7 +59,7 @@
#include "catalog/pg_rewrite.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
@@ -114,7 +114,7 @@ static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_
static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
-static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_subscription] = {Schema_pg_subscription};
+static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_sub] = {Schema_pg_sub};
/*
* Hash tables that index the relation cache
@@ -3825,8 +3825,8 @@ RelationCacheInitializePhase2(void)
Natts_pg_auth_members, Desc_pg_auth_members);
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
Natts_pg_shseclabel, Desc_pg_shseclabel);
- formrdesc("pg_subscription", SubscriptionRelation_Rowtype_Id, true,
- Natts_pg_subscription, Desc_pg_subscription);
+ formrdesc("pg_sub", SubscriptionRelation_Rowtype_Id, true,
+ Natts_pg_sub, Desc_pg_subscription);
#define NUM_CRITICAL_SHARED_RELS 5 /* fix if you change list above */
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 53d9ddf159..7d617c0cab 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -63,7 +63,7 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
@@ -776,8 +776,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionNameIndexId,
2,
{
- Anum_pg_subscription_subdbid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_subdbid,
+ Anum_pg_sub_subname,
0,
0
},
@@ -787,7 +787,7 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionObjectIndexId,
1,
{
- Anum_pg_subscription_oid,
+ Anum_pg_sub_oid,
0,
0,
0
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index dfe43968b8..cd53d73cee 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4216,7 +4216,7 @@ getSubscriptions(Archive *fout)
int n;
res = ExecuteSqlQuery(fout,
- "SELECT count(*) FROM pg_subscription "
+ "SELECT count(*) FROM pg_sub "
"WHERE subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
PGRES_TUPLES_OK);
@@ -4235,9 +4235,9 @@ getSubscriptions(Archive *fout)
appendPQExpBuffer(query,
"SELECT s.tableoid, s.oid, s.subname,"
"(%s s.subowner) AS rolname, "
- " s.subconninfo, s.subslotname, s.subsynccommit, "
+ " s.subconn, s.subslotname, s.subsynccommit, "
" s.subpublications "
- "FROM pg_subscription s "
+ "FROM pg_sub s "
"WHERE s.subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
username_subquery);
@@ -4249,7 +4249,7 @@ getSubscriptions(Archive *fout)
i_oid = PQfnumber(res, "oid");
i_subname = PQfnumber(res, "subname");
i_rolname = PQfnumber(res, "rolname");
- i_subconninfo = PQfnumber(res, "subconninfo");
+ i_subconninfo = PQfnumber(res, "subconn");
i_subslotname = PQfnumber(res, "subslotname");
i_subsynccommit = PQfnumber(res, "subsynccommit");
i_subpublications = PQfnumber(res, "subpublications");
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 8be303870f..66b2894978 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -354,10 +354,10 @@ DECLARE_UNIQUE_INDEX(pg_publication_rel_oid_index, 6112, on pg_publication_rel u
DECLARE_UNIQUE_INDEX(pg_publication_rel_prrelid_prpubid_index, 6113, on pg_publication_rel using btree(prrelid oid_ops, prpubid oid_ops));
#define PublicationRelPrrelidPrpubidIndexId 6113
-DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_sub using btree(oid oid_ops));
#define SubscriptionObjectIndexId 6114
-DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_sub using btree(subdbid oid_ops, subname name_ops));
#define SubscriptionNameIndexId 6115
DECLARE_UNIQUE_INDEX(pg_subscription_rel_srrelid_srsubid_index, 6117, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
diff --git a/src/include/catalog/pg_language.dat b/src/include/catalog/pg_language.dat
index 2e44a2730d..be6d96fd63 100644
--- a/src/include/catalog/pg_language.dat
+++ b/src/include/catalog/pg_language.dat
@@ -20,6 +20,6 @@
lanname => 'c', lanvalidator => 'fmgr_c_validator' },
{ oid => '14', oid_symbol => 'SQLlanguageId',
descr => 'SQL-language functions',
- lanname => 'sql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
+ lanname => 'pgsql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
]
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 61f2c2f5b4..b7a7ae8815 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2334,7 +2334,7 @@
proname => 'justify_days', prorettype => 'interval',
proargtypes => 'interval', prosrc => 'interval_justify_days' },
{ oid => '1176', descr => 'convert date and time to timestamp with time zone',
- proname => 'timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'date time',
prosrc => 'select cast(($1 + $2) as timestamp with time zone)' },
{ oid => '1178', descr => 'convert timestamp with time zone to date',
@@ -2387,16 +2387,16 @@
prosrc => 'interval_scale' },
{ oid => '1215', descr => 'get description for object id and catalog name',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0' },
{ oid => '1216', descr => 'get description for table column',
- proname => 'col_description', prolang => 'sql', procost => '100',
+ proname => 'col_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'pg_catalog.pg_class\'::pg_catalog.regclass and objsubid = $2' },
{ oid => '1993',
descr => 'get description for object id and shared catalog name',
- proname => 'shobj_description', prolang => 'sql', procost => '100',
+ proname => 'shobj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP)' },
@@ -2572,13 +2572,13 @@
prosrc => 'hashtidextended' },
{ oid => '1296',
- proname => 'timedate_pl', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'timedate_pl', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'time date', prosrc => 'select ($2 + $1)' },
{ oid => '1297',
proname => 'datetimetz_pl', prorettype => 'timestamptz',
proargtypes => 'date timetz', prosrc => 'datetimetz_timestamptz' },
{ oid => '1298',
- proname => 'timetzdate_pl', prolang => 'sql', prorettype => 'timestamptz',
+ proname => 'timetzdate_pl', prolang => 'pgsql', prorettype => 'timestamptz',
proargtypes => 'timetz date', prosrc => 'select ($2 + $1)' },
{ oid => '1299', descr => 'current transaction time',
proname => 'now', provolatile => 's', prorettype => 'timestamptz',
@@ -2620,17 +2620,17 @@
proargtypes => 'timestamptz timestamptz timestamptz timestamptz',
prosrc => 'overlaps_timestamp' },
{ oid => '1305', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1306', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz timestamptz timestamptz interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1307', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz timestamptz',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2639,15 +2639,15 @@
proname => 'overlaps', proisstrict => 'f', prorettype => 'bool',
proargtypes => 'time time time time', prosrc => 'overlaps_time' },
{ oid => '1309', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1310', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time time time interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1311', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time time',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2728,7 +2728,7 @@
# This form of obj_description is now deprecated, since it will fail if
# OIDs are not unique across system catalogs. Use the other form instead.
{ oid => '1348', descr => 'deprecated, use two-argument form instead',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and objsubid = 0' },
@@ -2812,7 +2812,7 @@
prosrc => 'textlen' },
{ oid => '1384', descr => 'extract field from date',
- proname => 'date_part', prolang => 'sql', prorettype => 'float8',
+ proname => 'date_part', prolang => 'pgsql', prorettype => 'float8',
proargtypes => 'text date',
prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time zone))' },
{ oid => '1385', descr => 'extract field from time',
@@ -2820,7 +2820,7 @@
prosrc => 'time_part' },
{ oid => '1386',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp with time zone), $1)' },
@@ -2935,7 +2935,7 @@
proname => 'box_div', prorettype => 'box', proargtypes => 'box point',
prosrc => 'box_div' },
{ oid => '1426',
- proname => 'path_contain_pt', prolang => 'sql', prorettype => 'bool',
+ proname => 'path_contain_pt', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'path point', prosrc => 'select pg_catalog.on_ppath($2, $1)' },
{ oid => '1428',
proname => 'poly_contain_pt', prorettype => 'bool',
@@ -3195,7 +3195,7 @@
proname => 'center', prorettype => 'point', proargtypes => 'circle',
prosrc => 'circle_center' },
{ oid => '1544', descr => 'convert circle to 12-vertex polygon',
- proname => 'polygon', prolang => 'sql', prorettype => 'polygon',
+ proname => 'polygon', prolang => 'pgsql', prorettype => 'polygon',
proargtypes => 'circle', prosrc => 'select pg_catalog.polygon(12, $1)' },
{ oid => '1545', descr => 'number of points',
proname => 'npoints', prorettype => 'int4', proargtypes => 'path',
@@ -3491,11 +3491,11 @@
proname => 'translate', prorettype => 'text', proargtypes => 'text text text',
prosrc => 'translate' },
{ oid => '879', descr => 'left-pad string to length',
- proname => 'lpad', prolang => 'sql', prorettype => 'text',
+ proname => 'lpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.lpad($1, $2, \' \')' },
{ oid => '880', descr => 'right-pad string to length',
- proname => 'rpad', prolang => 'sql', prorettype => 'text',
+ proname => 'rpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.rpad($1, $2, \' \')' },
{ oid => '881', descr => 'trim spaces from left end of string',
@@ -4086,7 +4086,7 @@
proname => 'inetpl', prorettype => 'inet', proargtypes => 'inet int8',
prosrc => 'inetpl' },
{ oid => '2631',
- proname => 'int8pl_inet', prolang => 'sql', prorettype => 'inet',
+ proname => 'int8pl_inet', prolang => 'pgsql', prorettype => 'inet',
proargtypes => 'int8 inet', prosrc => 'select $2 + $1' },
{ oid => '2632',
proname => 'inetmi_int8', prorettype => 'inet', proargtypes => 'inet int8',
@@ -4218,13 +4218,13 @@
proname => 'round', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_round' },
{ oid => '1708', descr => 'value rounded to \'scale\' of zero',
- proname => 'round', prolang => 'sql', prorettype => 'numeric',
+ proname => 'round', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.round($1,0)' },
{ oid => '1709', descr => 'value truncated to \'scale\'',
proname => 'trunc', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_trunc' },
{ oid => '1710', descr => 'value truncated to \'scale\' of zero',
- proname => 'trunc', prolang => 'sql', prorettype => 'numeric',
+ proname => 'trunc', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.trunc($1,0)' },
{ oid => '1711', descr => 'nearest integer >= value',
proname => 'ceil', prorettype => 'numeric', proargtypes => 'numeric',
@@ -4324,10 +4324,10 @@
proname => 'numeric', prorettype => 'numeric', proargtypes => 'int4',
prosrc => 'int4_numeric' },
{ oid => '1741', descr => 'base 10 logarithm',
- proname => 'log', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1481', descr => 'base 10 logarithm',
- proname => 'log10', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log10', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1742', descr => 'convert float4 to numeric',
proname => 'numeric', prorettype => 'numeric', proargtypes => 'float4',
@@ -4460,7 +4460,7 @@
proname => 'quote_literal', prorettype => 'text', proargtypes => 'text',
prosrc => 'quote_literal' },
{ oid => '1285', descr => 'quote a data value for usage in a querystring',
- proname => 'quote_literal', prolang => 'sql', provolatile => 's',
+ proname => 'quote_literal', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_literal($1::pg_catalog.text)' },
{ oid => '1289',
@@ -4469,7 +4469,7 @@
proargtypes => 'text', prosrc => 'quote_nullable' },
{ oid => '1290',
descr => 'quote a possibly-null data value for usage in a querystring',
- proname => 'quote_nullable', prolang => 'sql', proisstrict => 'f',
+ proname => 'quote_nullable', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_nullable($1::pg_catalog.text)' },
@@ -4508,13 +4508,13 @@
prorettype => 'text', proargtypes => 'text', prosrc => 'text_format_nv' },
{ oid => '1810', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bytea', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1811', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'text', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1812', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bit', prosrc => 'select pg_catalog.length($1)' },
# Selectivity estimators for LIKE and related operators
@@ -4833,7 +4833,7 @@
prosrc => 'to_ascii_encname' },
{ oid => '1848',
- proname => 'interval_pl_time', prolang => 'sql', prorettype => 'time',
+ proname => 'interval_pl_time', prolang => 'pgsql', prorettype => 'time',
proargtypes => 'interval time', prosrc => 'select $2 + $1' },
{ oid => '1850',
@@ -5249,12 +5249,12 @@
proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
prosrc => 'pg_stat_get_wal_receiver' },
{ oid => '6118', descr => 'statistics: information about subscription',
- proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
+ proname => 'pg_stat_get_sub', proisstrict => 'f', provolatile => 's',
proparallel => 'r', prorettype => 'record', proargtypes => 'oid',
proallargtypes => '{oid,oid,oid,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}',
proargmodes => '{i,o,o,o,o,o,o,o,o}',
proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}',
- prosrc => 'pg_stat_get_subscription' },
+ prosrc => 'pg_stat_get_sub' },
{ oid => '2026', descr => 'statistics: current backend PID',
proname => 'pg_backend_pid', provolatile => 's', proparallel => 'r',
prorettype => 'int4', proargtypes => '', prosrc => 'pg_backend_pid' },
@@ -5663,11 +5663,11 @@
proargtypes => 'timetz int4', prosrc => 'timetz_scale' },
{ oid => '2003',
- proname => 'textanycat', prolang => 'sql', provolatile => 's',
+ proname => 'textanycat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'text anynonarray',
prosrc => 'select $1 || $2::pg_catalog.text' },
{ oid => '2004',
- proname => 'anytextcat', prolang => 'sql', provolatile => 's',
+ proname => 'anytextcat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anynonarray text',
prosrc => 'select $1::pg_catalog.text || $2' },
@@ -5767,15 +5767,15 @@
proargtypes => 'timestamp timestamp timestamp timestamp',
prosrc => 'overlaps_timestamp' },
{ oid => '2042', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '2043', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp timestamp timestamp interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '2044', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp timestamp',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
{ oid => '2045', descr => 'less-equal-greater',
@@ -5841,7 +5841,7 @@
proargtypes => 'timestamp timestamp', prosrc => 'timestamp_age' },
{ oid => '2059',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamp',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp without time zone), $1)' },
@@ -5862,7 +5862,7 @@
proname => 'substring', prorettype => 'text', proargtypes => 'text text',
prosrc => 'textregexsubstr' },
{ oid => '2074', descr => 'extract text matching SQL regular expression',
- proname => 'substring', prolang => 'sql', prorettype => 'text',
+ proname => 'substring', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text text text',
prosrc => 'select pg_catalog.substring($1, pg_catalog.similar_to_escape($2, $3))' },
@@ -6201,11 +6201,11 @@
proname => 'pg_sleep', provolatile => 'v', prorettype => 'void',
proargtypes => 'float8', prosrc => 'pg_sleep' },
{ oid => '3935', descr => 'sleep for the specified interval',
- proname => 'pg_sleep_for', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_for', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'interval',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from pg_catalog.clock_timestamp() operator(pg_catalog.+) $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '3936', descr => 'sleep until the specified time',
- proname => 'pg_sleep_until', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_until', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '315', descr => 'Is JIT compilation available in this session?',
@@ -7016,7 +7016,7 @@
proargtypes => 'name', prosrc => 'pg_database_size_name' },
{ oid => '2325',
descr => 'disk space usage for the main fork of the specified table or index',
- proname => 'pg_relation_size', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_relation_size', prolang => 'pgsql', provolatile => 'v',
prorettype => 'int8', proargtypes => 'regclass',
prosrc => 'select pg_catalog.pg_relation_size($1, \'main\')' },
{ oid => '2332',
@@ -7898,21 +7898,21 @@
# formerly-missing interval + datetime operators
{ oid => '2546',
- proname => 'interval_pl_date', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'interval_pl_date', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'interval date', prosrc => 'select $2 + $1' },
{ oid => '2547',
- proname => 'interval_pl_timetz', prolang => 'sql', prorettype => 'timetz',
+ proname => 'interval_pl_timetz', prolang => 'pgsql', prorettype => 'timetz',
proargtypes => 'interval timetz', prosrc => 'select $2 + $1' },
{ oid => '2548',
- proname => 'interval_pl_timestamp', prolang => 'sql',
+ proname => 'interval_pl_timestamp', prolang => 'pgsql',
prorettype => 'timestamp', proargtypes => 'interval timestamp',
prosrc => 'select $2 + $1' },
{ oid => '2549',
- proname => 'interval_pl_timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'interval_pl_timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'interval timestamptz',
prosrc => 'select $2 + $1' },
{ oid => '2550',
- proname => 'integer_pl_date', prolang => 'sql', prorettype => 'date',
+ proname => 'integer_pl_date', prolang => 'pgsql', prorettype => 'date',
proargtypes => 'int4 date', prosrc => 'select $2 + $1' },
{ oid => '2556', descr => 'get OIDs of databases in a tablespace',
@@ -8301,7 +8301,7 @@
proname => 'xpath', prorettype => '_xml', proargtypes => 'text xml _text',
prosrc => 'xpath' },
{ oid => '2932', descr => 'evaluate XPath expression',
- proname => 'xpath', prolang => 'sql', prorettype => '_xml',
+ proname => 'xpath', prolang => 'pgsql', prorettype => '_xml',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath($1, $2, \'{}\'::pg_catalog.text[])' },
@@ -8314,7 +8314,7 @@
proname => 'xpath_exists', prorettype => 'bool',
proargtypes => 'text xml _text', prosrc => 'xpath_exists' },
{ oid => '3050', descr => 'test XML value against XPath expression',
- proname => 'xpath_exists', prolang => 'sql', prorettype => 'bool',
+ proname => 'xpath_exists', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '3051', descr => 'determine if a string is well formed XML',
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_sub.h
similarity index 88%
rename from src/include/catalog/pg_subscription.h
rename to src/include/catalog/pg_sub.h
index 0a756d42d8..4faf0aa370 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_sub.h
@@ -1,12 +1,12 @@
/* -------------------------------------------------------------------------
*
- * pg_subscription.h
+ * pg_sub.h
* definition of the "subscription" system catalog (pg_subscription)
*
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * src/include/catalog/pg_subscription.h
+ * src/include/catalog/pg_sub.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
@@ -18,7 +18,7 @@
#define PG_SUBSCRIPTION_H
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_d.h"
+#include "catalog/pg_sub_d.h"
#include "nodes/pg_list.h"
@@ -36,7 +36,7 @@
*
* NOTE: When adding a column, also update system_views.sql.
*/
-CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
+CATALOG(pg_sub,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
@@ -45,12 +45,12 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
Oid subowner; /* Owner of the subscription */
- bool subenabled; /* True if the subscription is enabled (the
+ bool subactive; /* True if the subscription is enabled (the
* worker should be running) */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* Connection string to the publisher */
- text subconninfo BKI_FORCE_NOT_NULL;
+ text subconn BKI_FORCE_NOT_NULL;
/* Slot name on publisher */
NameData subslotname;
diff --git a/src/include/catalog/toasting.h b/src/include/catalog/toasting.h
index 51491c4513..5372bf88a1 100644
--- a/src/include/catalog/toasting.h
+++ b/src/include/catalog/toasting.h
@@ -95,7 +95,7 @@ DECLARE_TOAST(pg_shdescription, 2846, 2847);
DECLARE_TOAST(pg_shseclabel, 4060, 4061);
#define PgShseclabelToastTable 4060
#define PgShseclabelToastIndex 4061
-DECLARE_TOAST(pg_subscription, 4183, 4184);
+DECLARE_TOAST(pg_sub, 4183, 4184);
#define PgSubscriptionToastTable 4183
#define PgSubscriptionToastIndex 4184
DECLARE_TOAST(pg_tablespace, 4185, 4186);
diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h
index 8ed7e45056..8d913cffe3 100644
--- a/src/include/replication/worker_internal.h
+++ b/src/include/replication/worker_internal.h
@@ -15,7 +15,7 @@
#include <signal.h>
#include "access/xlogdefs.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
On 2020-Jun-08, Anastasia Lubennikova wrote:
In this version I rebased test patches,� added some more comments, fixed
memory allocation issue and also removed code that handles ACLs on
languages. They require a lot of specific handling, while I doubt that their
signatures, which consist of language name only, are subject to change in
any future versions.
I'm thinking what's a good way to have a test that's committable. Maybe
it would work to add a TAP test to pg_upgrade that runs initdb, does a
few GRANTS as per your attachment, then runs pg_upgrade? Currently the
pg_upgrade tests are not TAP ... we'd have to revive
/messages/by-id/20180126080026.GI17847@paquier.xyz
(Some progress was already made on the buildfarm front to permit this)
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On 08.06.2020 19:31, Alvaro Herrera wrote:
On 2020-Jun-08, Anastasia Lubennikova wrote:
In this version I rebased test patches, added some more comments, fixed
memory allocation issue and also removed code that handles ACLs on
languages. They require a lot of specific handling, while I doubt that their
signatures, which consist of language name only, are subject to change in
any future versions.I'm thinking what's a good way to have a test that's committable. Maybe
it would work to add a TAP test to pg_upgrade that runs initdb, does a
few GRANTS as per your attachment, then runs pg_upgrade? Currently the
pg_upgrade tests are not TAP ... we'd have to revive
/messages/by-id/20180126080026.GI17847@paquier.xyz
(Some progress was already made on the buildfarm front to permit this)
I would be glad to add some test, but it seems to me that the infrastructure
changes for cross-version pg_upgrade test is much more complicated task than
this modest bugfix. Besides, I've read the discussion and it seems that
Michael
is not going to continue this work.
Attached v10 patch contains more fix for uninitialized variable.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v10.patchtext/x-patch; charset=UTF-8; name=pg_upgrade_ACL_check_v10.patchDownload
commit f98c26fca3d80134a7a3cf8424d8c23891c5f2b9
Author: anastasia <a.lubennikova@postgrespro.ru>
Date: Mon Jun 8 18:34:14 2020 +0300
pg_upgrade_ACL_check_v10.patch
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 00aef855dc..94e8528a3a 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -142,6 +143,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -161,6 +164,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -443,6 +447,223 @@ check_databases_are_compatible(void)
}
}
+/*
+ * Find the location of the last dot, return NULL if not found.
+ */
+static char *
+last_dot_location(const char *identity)
+{
+ const char *p,
+ *ret = NULL;
+
+ for (p = identity; *p; p++)
+ if (*p == '.')
+ ret = p;
+ return unconstify(char *, ret);
+}
+
+/*
+ * check_for_changed_signatures()
+ *
+ * Check that the old cluster doesn't have non-default ACL's for system objects
+ * (relations, attributes, functions and procedures) which have different
+ * signatures in the new cluster. Otherwise generate revoke_objects.sql.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ char subquery[QUERY_ALLOC];
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ prep_status("Checking for system objects with non-default ACL");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+ /*
+ * The old cluster doesn't have system objects with non-default ACL so
+ * quickly exit.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "revoke_objects.sql");
+
+ snprintf(subquery, sizeof(subquery),
+ /* Get system relations which created in pg_catalog */
+ "SELECT 'pg_class'::regclass classid, oid objid, 0 objsubid "
+ "FROM pg_catalog.pg_class "
+ "WHERE relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system relations attributes which created in pg_catalog */
+ "SELECT 'pg_class'::regclass, att.attrelid, att.attnum "
+ "FROM pg_catalog.pg_class rel "
+ "INNER JOIN pg_catalog.pg_attribute att ON rel.oid = att.attrelid "
+ "WHERE rel.relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system functions and procedure which created in pg_catalog */
+ "SELECT 'pg_proc'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_proc "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace ");
+
+ conn = connectToServer(&new_cluster, "template1");
+ res = executeQueryOrDie(conn,
+ "SELECT ident.type, ident.identity "
+ "FROM (%s) obj, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " obj.classid, obj.objid, obj.objsubid) ident "
+ /*
+ * Don't rely on database collation, since we use strcmp
+ * comparison to find non-default ACLs.
+ */
+ "ORDER BY ident.identity COLLATE \"C\";", subquery);
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ * For every database check system objects with non-default ACL.
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool report = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(aclinfo->obj_ident,
+ PQgetvalue(res, objnum, i_obj_ident));
+
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ {
+ report = true;
+ break;
+ }
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ objnum++;
+ break;
+ }
+ else
+ objnum++;
+ }
+
+ if (report)
+ {
+ found_changed = true;
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %s\n",
+ output_path, strerror(errno));
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+ /* Handle columns separately */
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ {
+ char *pdot = last_dot_location(aclinfo->obj_ident);
+ PQExpBufferData ident_buf;
+
+ if (pdot == NULL || *(pdot + 1) == '\0')
+ pg_fatal("invalid column identity \"%s\"",
+ aclinfo->obj_ident);
+
+ initPQExpBuffer(&ident_buf);
+ appendBinaryPQExpBuffer(&ident_buf, aclinfo->obj_ident,
+ pdot - aclinfo->obj_ident);
+
+ fprintf(script, "REVOKE ALL (%s) ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ pdot + 1, ident_buf.data,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ termPQExpBuffer(&ident_buf);
+ }
+ /*
+ * For relations except sequences we don't need to specify
+ * the object type.
+ */
+ else if (aclinfo->is_relation &&
+ strcmp(aclinfo->obj_type, "sequence") != 0)
+ fprintf(script, "REVOKE ALL ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ /* Other object types */
+ else
+ fprintf(script, "REVOKE ALL ON %s %s FROM %s;\n",
+ aclinfo->obj_type,
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* create_script_for_cluster_analyze()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 7e524ea192..1598b40947 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,114 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Fill AclInfo array with information about system objects that
+ * have non-default ACL.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos = NULL;
+ AclInfo *curr = NULL;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_rolname,
+ i_is_relation;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get relations, attributes, functions and procedures. Some system
+ * objects like views are not pinned, but these type of objects are
+ * created in pg_catalog schema.
+ */
+ "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, "
+ " CASE WHEN shd.classid = 'pg_class'::regclass THEN true "
+ " ELSE false "
+ " END is_relation "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj "
+ /* 'a' is for SHARED_DEPENDENCY_ACL */
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid IN ('pg_proc'::regclass, 'pg_class'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ * Don't rely on database collation, since we use strcmp
+ * comparison below.
+ */
+ "ORDER BY obj.identity COLLATE \"C\";", dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_rolname = PQfnumber(res, "rolename");
+ i_is_relation = PQfnumber(res, "is_relation");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBuffer roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+ curr->is_relation = PQgetvalue(res, aclnum, i_is_relation)[0] == 't';
+
+ roles_buf = createPQExpBuffer();
+ initPQExpBuffer(roles_buf);
+
+ /*
+ * For each object gather string of role names mentioned in ACL
+ * in a format convenient for further use in REVOKE statement.
+ */
+ while (aclnum < PQntuples(res) &&
+ strcmp(curr->obj_ident, PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf->len != 0)
+ appendPQExpBufferChar(roles_buf, ',');
+
+ appendPQExpBufferStr(roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+
+ curr->role_names = pg_strdup(roles_buf->data);
+ destroyPQExpBuffer(roles_buf);
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -384,6 +494,10 @@ get_db_infos(ClusterInfo *cluster)
dbinfos[tupnum].db_ctype = pg_strdup(PQgetvalue(res, tupnum, i_datctype));
snprintf(dbinfos[tupnum].db_tablespace, sizeof(dbinfos[tupnum].db_tablespace), "%s",
PQgetvalue(res, tupnum, i_spclocation));
+
+ /* initialize clean array */
+ dbinfos[tupnum].non_def_acl_arr.nacls = 0;
+ dbinfos[tupnum].non_def_acl_arr.aclinfos = NULL;
}
PQclear(res);
@@ -595,6 +709,9 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+
+ if (&db_arr->dbs[dbnum].non_def_acl_arr.nacls > 0)
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +737,23 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+
+ pg_free(acl_arr->aclinfos);
+ acl_arr->aclinfos = NULL;
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 8b90cefbe0..33bbe2d233 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -147,6 +147,26 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Information about database object needed to check
+ * if its signature has changed between versions
+ * and generate REVOKE statement if necessary.
+ */
+typedef struct
+{
+ char *obj_type; /* object type */
+ char *obj_ident; /* complete object identity */
+ bool is_relation; /* if the object is relation */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -183,6 +203,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -390,6 +412,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
test_rename_catalog_objects_v10text/plain; charset=UTF-8; name=test_rename_catalog_objects_v10Download
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 9499bb33e5..4fdd367a6f 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -67,7 +67,7 @@ CATALOG_HEADERS := \
pg_foreign_table.h pg_policy.h pg_replication_origin.h \
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
- pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
+ pg_sequence.h pg_publication.h pg_publication_rel.h pg_sub.h \
pg_subscription_rel.h
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index cb2c4972ad..7c4247e2c9 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -50,7 +50,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 7d6acaed92..e251b410e6 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -37,7 +37,7 @@
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/toasting.h"
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 5565e6fc19..38ac1f8c53 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 3e07fb107e..cba7e55ce0 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -42,7 +42,7 @@ SET search_path TO information_schema;
/* Expand any 1-D array into a set with integers 1..N */
CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
RETURNS SETOF RECORD
- LANGUAGE sql STRICT IMMUTABLE PARALLEL SAFE
+ LANGUAGE pgsql STRICT IMMUTABLE PARALLEL SAFE
AS 'select $1[s], s - pg_catalog.array_lower($1,1) + 1
from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
pg_catalog.array_upper($1,1),
@@ -51,7 +51,7 @@ CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
/* Given an index's OID and an underlying-table column number, return the
* column's position in the index (NULL if not there) */
CREATE FUNCTION _pg_index_position(oid, smallint) RETURNS int
- LANGUAGE sql STRICT STABLE
+ LANGUAGE pgsql STRICT STABLE
AS $$
SELECT (ss.a).n FROM
(SELECT information_schema._pg_expandarray(indkey) AS a
@@ -60,7 +60,7 @@ SELECT (ss.a).n FROM
$$;
CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -68,7 +68,7 @@ CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
$$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typbasetype ELSE $1.atttypid END$$;
CREATE FUNCTION _pg_truetypmod(pg_attribute, pg_type) RETURNS int4
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -78,7 +78,7 @@ $$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typtypmod ELSE $1.atttypmod END$$;
-- these functions encapsulate knowledge about the encoding of typmod:
CREATE FUNCTION _pg_char_max_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -94,7 +94,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_char_octet_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -110,7 +110,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -131,7 +131,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision_radix(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -143,7 +143,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_scale(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -159,7 +159,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_datetime_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -175,7 +175,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_interval_type(typid oid, mod int4) RETURNS text
- LANGUAGE sql
+ LANGUAGE pgsql
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -1477,7 +1477,7 @@ CREATE VIEW routines AS
CAST(null AS cardinal_number) AS maximum_cardinality,
CAST(CASE WHEN p.prokind <> 'p' THEN 0 END AS sql_identifier) AS dtd_identifier,
- CAST(CASE WHEN l.lanname = 'sql' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
+ CAST(CASE WHEN l.lanname = 'pgsql' THEN 'PGSQL' ELSE 'EXTERNAL' END AS character_data)
AS routine_body,
CAST(
CASE WHEN pg_has_role(p.proowner, 'USAGE') THEN p.prosrc ELSE null END
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 84463f76fc..cf2fb78187 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -52,7 +52,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
@@ -506,10 +506,10 @@ static const ObjectPropertyType ObjectProperty[] =
SubscriptionObjectIndexId,
SUBSCRIPTIONOID,
SUBSCRIPTIONNAME,
- Anum_pg_subscription_oid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_oid,
+ Anum_pg_sub_subname,
InvalidAttrNumber,
- Anum_pg_subscription_subowner,
+ Anum_pg_sub_subowner,
InvalidAttrNumber,
OBJECT_SUBSCRIPTION,
true
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index f776e821b3..a2e4b61bc0 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -40,7 +40,7 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c
index cb15731115..092e059c73 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_subscription.c
@@ -20,7 +20,7 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/indexing.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
@@ -64,12 +64,12 @@ GetSubscription(Oid subid, bool missing_ok)
sub->dbid = subform->subdbid;
sub->name = pstrdup(NameStr(subform->subname));
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subconninfo,
+ Anum_pg_sub_subconn,
&isnull);
Assert(!isnull);
sub->conninfo = TextDatumGetCString(datum);
@@ -77,7 +77,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subslotname,
+ Anum_pg_sub_subslotname,
&isnull);
if (!isnull)
sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));
@@ -87,7 +87,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get synccommit */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subsynccommit,
+ Anum_pg_sub_subsynccommit,
&isnull);
Assert(!isnull);
sub->synccommit = TextDatumGetCString(datum);
@@ -95,7 +95,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get publications */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subpublications,
+ Anum_pg_sub_subpublications,
&isnull);
Assert(!isnull);
sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
@@ -121,7 +121,7 @@ CountDBSubscriptions(Oid dbid)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- Anum_pg_subscription_subdbid,
+ Anum_pg_sub_subdbid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
@@ -163,7 +163,7 @@ get_subscription_oid(const char *subname, bool missing_ok)
{
Oid oid;
- oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(subname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index 56420bbc9d..2c37eabff4 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -478,7 +478,7 @@ SELECT
l.provider, l.label
FROM
pg_shseclabel l
- JOIN pg_subscription s ON l.classoid = s.tableoid AND l.objoid = s.oid
+ JOIN pg_sub s ON l.classoid = s.tableoid AND l.objoid = s.oid
UNION ALL
SELECT
l.objoid, l.classoid, 0::int4 AS objsubid,
@@ -826,19 +826,19 @@ CREATE VIEW pg_stat_wal_receiver AS
FROM pg_stat_get_wal_receiver() s
WHERE s.pid IS NOT NULL;
-CREATE VIEW pg_stat_subscription AS
+CREATE VIEW pg_stat_sub AS
SELECT
su.oid AS subid,
su.subname,
st.pid,
st.relid,
- st.received_lsn,
+ st.received_lsn received_location,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_lsn latest_end_location,
st.latest_end_time
- FROM pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL) st
+ FROM pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL) st
ON (st.subid = su.oid);
CREATE VIEW pg_stat_ssl AS
@@ -1124,9 +1124,9 @@ CREATE VIEW pg_replication_origin_status AS
REVOKE ALL ON pg_replication_origin_status FROM public;
-- All columns of pg_subscription except subconninfo are readable.
-REVOKE ALL ON pg_subscription FROM public;
-GRANT SELECT (subdbid, subname, subowner, subenabled, subslotname, subpublications)
- ON pg_subscription TO public;
+REVOKE ALL ON pg_sub FROM public;
+GRANT SELECT (subdbid, subname, subowner, subactive, subslotname, subpublications)
+ ON pg_sub TO public;
--
@@ -1176,7 +1176,7 @@ FROM pg_catalog.ts_parse(
) AS tt
WHERE tt.tokid = parse.tokid
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(regconfig,text) IS
'debug function for text search configuration';
@@ -1192,7 +1192,7 @@ RETURNS SETOF record AS
$$
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1);
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE PGSQL STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(text) IS
'debug function for current text search configuration';
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index b11ebf0f61..27d4f6dfcc 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -35,7 +35,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index f27c3fe8c1..b87df4d80d 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -38,7 +38,7 @@
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 9ebb026187..088c1f357e 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -23,7 +23,7 @@
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
@@ -310,8 +310,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
Relation rel;
ObjectAddress myself;
Oid subid;
- bool nulls[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
Oid owner = GetUserId();
HeapTuple tup;
bool connect;
@@ -362,7 +362,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Check if name is used */
- subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(stmt->subname));
if (OidIsValid(subid))
{
@@ -393,23 +393,23 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
memset(nulls, false, sizeof(nulls));
subid = GetNewOidWithIndex(rel, SubscriptionObjectIndexId,
- Anum_pg_subscription_oid);
- values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
- values[Anum_pg_subscription_subname - 1] =
+ Anum_pg_sub_oid);
+ values[Anum_pg_sub_oid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
+ values[Anum_pg_sub_subname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
- values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
- values[Anum_pg_subscription_subenabled - 1] = BoolGetDatum(enabled);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subowner - 1] = ObjectIdGetDatum(owner);
+ values[Anum_pg_sub_subactive - 1] = BoolGetDatum(enabled);
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(conninfo);
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- values[Anum_pg_subscription_subsynccommit - 1] =
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(publications);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -623,9 +623,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
{
Relation rel;
ObjectAddress myself;
- bool nulls[Natts_pg_subscription];
- bool replaces[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ bool replaces[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
HeapTuple tup;
Oid subid;
bool update_tuple = false;
@@ -683,18 +683,18 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
"slot_name = NONE")));
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- replaces[Anum_pg_subscription_subslotname - 1] = true;
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ replaces[Anum_pg_sub_subslotname - 1] = true;
}
if (synchronous_commit)
{
- values[Anum_pg_subscription_subsynccommit - 1] =
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- replaces[Anum_pg_subscription_subsynccommit - 1] = true;
+ replaces[Anum_pg_sub_subsynccommit - 1] = true;
}
update_tuple = true;
@@ -716,9 +716,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot enable subscription that does not have a slot name")));
- values[Anum_pg_subscription_subenabled - 1] =
+ values[Anum_pg_sub_subactive - 1] =
BoolGetDatum(enabled);
- replaces[Anum_pg_subscription_subenabled - 1] = true;
+ replaces[Anum_pg_sub_subactive - 1] = true;
if (enabled)
ApplyLauncherWakeupAtCommit();
@@ -733,9 +733,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
/* Check the connection info string. */
walrcv_check_conninfo(stmt->conninfo);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subconn - 1] =
CStringGetTextDatum(stmt->conninfo);
- replaces[Anum_pg_subscription_subconninfo - 1] = true;
+ replaces[Anum_pg_sub_subconn - 1] = true;
update_tuple = true;
break;
@@ -748,9 +748,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
NULL, NULL, NULL, ©_data,
NULL, &refresh);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(stmt->publication);
- replaces[Anum_pg_subscription_subpublications - 1] = true;
+ replaces[Anum_pg_sub_subpublications - 1] = true;
update_tuple = true;
@@ -884,19 +884,19 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
/* Get subname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subname, &isnull);
+ Anum_pg_sub_subname, &isnull);
Assert(!isnull);
subname = pstrdup(NameStr(*DatumGetName(datum)));
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subconninfo, &isnull);
+ Anum_pg_sub_subconn, &isnull);
Assert(!isnull);
conninfo = TextDatumGetCString(datum);
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subslotname, &isnull);
+ Anum_pg_sub_subslotname, &isnull);
if (!isnull)
slotname = pstrdup(NameStr(*DatumGetName(datum)));
else
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index aec885e987..375f7a598d 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -22,7 +22,7 @@
#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "funcapi.h"
#include "libpq/pqsignal.h"
@@ -95,7 +95,7 @@ static void logicalrep_worker_cleanup(LogicalRepWorker *worker);
static bool on_commit_launcher_wakeup = false;
-Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
+Datum pg_stat_get_sub(PG_FUNCTION_ARGS);
/*
@@ -147,7 +147,7 @@ get_subscription_list(void)
sub->oid = subform->oid;
sub->dbid = subform->subdbid;
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->name = pstrdup(NameStr(subform->subname));
/* We don't fill fields we are not interested in. */
@@ -1068,7 +1068,7 @@ IsLogicalLauncher(void)
* Returns state of the subscriptions.
*/
Datum
-pg_stat_get_subscription(PG_FUNCTION_ARGS)
+pg_stat_get_sub(PG_FUNCTION_ARGS)
{
#define PG_STAT_GET_SUBSCRIPTION_COLS 8
Oid subid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index a752a1224d..4e35ad2aec 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -31,7 +31,7 @@
#include "catalog/namespace.h"
#include "catalog/partition.h"
#include "catalog/pg_inherits.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "commands/tablecmds.h"
#include "commands/trigger.h"
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 0b9eb00d2d..f54ac3eeab 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -59,7 +59,7 @@
#include "catalog/pg_rewrite.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
@@ -114,7 +114,7 @@ static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_
static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
-static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_subscription] = {Schema_pg_subscription};
+static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_sub] = {Schema_pg_sub};
/*
* Hash tables that index the relation cache
@@ -3825,8 +3825,8 @@ RelationCacheInitializePhase2(void)
Natts_pg_auth_members, Desc_pg_auth_members);
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
Natts_pg_shseclabel, Desc_pg_shseclabel);
- formrdesc("pg_subscription", SubscriptionRelation_Rowtype_Id, true,
- Natts_pg_subscription, Desc_pg_subscription);
+ formrdesc("pg_sub", SubscriptionRelation_Rowtype_Id, true,
+ Natts_pg_sub, Desc_pg_subscription);
#define NUM_CRITICAL_SHARED_RELS 5 /* fix if you change list above */
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 53d9ddf159..7d617c0cab 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -63,7 +63,7 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
@@ -776,8 +776,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionNameIndexId,
2,
{
- Anum_pg_subscription_subdbid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_subdbid,
+ Anum_pg_sub_subname,
0,
0
},
@@ -787,7 +787,7 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionObjectIndexId,
1,
{
- Anum_pg_subscription_oid,
+ Anum_pg_sub_oid,
0,
0,
0
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index dfe43968b8..cd53d73cee 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4216,7 +4216,7 @@ getSubscriptions(Archive *fout)
int n;
res = ExecuteSqlQuery(fout,
- "SELECT count(*) FROM pg_subscription "
+ "SELECT count(*) FROM pg_sub "
"WHERE subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
PGRES_TUPLES_OK);
@@ -4235,9 +4235,9 @@ getSubscriptions(Archive *fout)
appendPQExpBuffer(query,
"SELECT s.tableoid, s.oid, s.subname,"
"(%s s.subowner) AS rolname, "
- " s.subconninfo, s.subslotname, s.subsynccommit, "
+ " s.subconn, s.subslotname, s.subsynccommit, "
" s.subpublications "
- "FROM pg_subscription s "
+ "FROM pg_sub s "
"WHERE s.subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
username_subquery);
@@ -4249,7 +4249,7 @@ getSubscriptions(Archive *fout)
i_oid = PQfnumber(res, "oid");
i_subname = PQfnumber(res, "subname");
i_rolname = PQfnumber(res, "rolname");
- i_subconninfo = PQfnumber(res, "subconninfo");
+ i_subconninfo = PQfnumber(res, "subconn");
i_subslotname = PQfnumber(res, "subslotname");
i_subsynccommit = PQfnumber(res, "subsynccommit");
i_subpublications = PQfnumber(res, "subpublications");
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 8be303870f..66b2894978 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -354,10 +354,10 @@ DECLARE_UNIQUE_INDEX(pg_publication_rel_oid_index, 6112, on pg_publication_rel u
DECLARE_UNIQUE_INDEX(pg_publication_rel_prrelid_prpubid_index, 6113, on pg_publication_rel using btree(prrelid oid_ops, prpubid oid_ops));
#define PublicationRelPrrelidPrpubidIndexId 6113
-DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_sub using btree(oid oid_ops));
#define SubscriptionObjectIndexId 6114
-DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
+DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_sub using btree(subdbid oid_ops, subname name_ops));
#define SubscriptionNameIndexId 6115
DECLARE_UNIQUE_INDEX(pg_subscription_rel_srrelid_srsubid_index, 6117, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
diff --git a/src/include/catalog/pg_language.dat b/src/include/catalog/pg_language.dat
index 2e44a2730d..be6d96fd63 100644
--- a/src/include/catalog/pg_language.dat
+++ b/src/include/catalog/pg_language.dat
@@ -20,6 +20,6 @@
lanname => 'c', lanvalidator => 'fmgr_c_validator' },
{ oid => '14', oid_symbol => 'SQLlanguageId',
descr => 'SQL-language functions',
- lanname => 'sql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
+ lanname => 'pgsql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
]
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 61f2c2f5b4..b7a7ae8815 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2334,7 +2334,7 @@
proname => 'justify_days', prorettype => 'interval',
proargtypes => 'interval', prosrc => 'interval_justify_days' },
{ oid => '1176', descr => 'convert date and time to timestamp with time zone',
- proname => 'timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'date time',
prosrc => 'select cast(($1 + $2) as timestamp with time zone)' },
{ oid => '1178', descr => 'convert timestamp with time zone to date',
@@ -2387,16 +2387,16 @@
prosrc => 'interval_scale' },
{ oid => '1215', descr => 'get description for object id and catalog name',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0' },
{ oid => '1216', descr => 'get description for table column',
- proname => 'col_description', prolang => 'sql', procost => '100',
+ proname => 'col_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'pg_catalog.pg_class\'::pg_catalog.regclass and objsubid = $2' },
{ oid => '1993',
descr => 'get description for object id and shared catalog name',
- proname => 'shobj_description', prolang => 'sql', procost => '100',
+ proname => 'shobj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP)' },
@@ -2572,13 +2572,13 @@
prosrc => 'hashtidextended' },
{ oid => '1296',
- proname => 'timedate_pl', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'timedate_pl', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'time date', prosrc => 'select ($2 + $1)' },
{ oid => '1297',
proname => 'datetimetz_pl', prorettype => 'timestamptz',
proargtypes => 'date timetz', prosrc => 'datetimetz_timestamptz' },
{ oid => '1298',
- proname => 'timetzdate_pl', prolang => 'sql', prorettype => 'timestamptz',
+ proname => 'timetzdate_pl', prolang => 'pgsql', prorettype => 'timestamptz',
proargtypes => 'timetz date', prosrc => 'select ($2 + $1)' },
{ oid => '1299', descr => 'current transaction time',
proname => 'now', provolatile => 's', prorettype => 'timestamptz',
@@ -2620,17 +2620,17 @@
proargtypes => 'timestamptz timestamptz timestamptz timestamptz',
prosrc => 'overlaps_timestamp' },
{ oid => '1305', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1306', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz timestamptz timestamptz interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1307', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz timestamptz',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2639,15 +2639,15 @@
proname => 'overlaps', proisstrict => 'f', prorettype => 'bool',
proargtypes => 'time time time time', prosrc => 'overlaps_time' },
{ oid => '1309', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1310', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time time time interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1311', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time time',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2728,7 +2728,7 @@
# This form of obj_description is now deprecated, since it will fail if
# OIDs are not unique across system catalogs. Use the other form instead.
{ oid => '1348', descr => 'deprecated, use two-argument form instead',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'pgsql', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and objsubid = 0' },
@@ -2812,7 +2812,7 @@
prosrc => 'textlen' },
{ oid => '1384', descr => 'extract field from date',
- proname => 'date_part', prolang => 'sql', prorettype => 'float8',
+ proname => 'date_part', prolang => 'pgsql', prorettype => 'float8',
proargtypes => 'text date',
prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time zone))' },
{ oid => '1385', descr => 'extract field from time',
@@ -2820,7 +2820,7 @@
prosrc => 'time_part' },
{ oid => '1386',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp with time zone), $1)' },
@@ -2935,7 +2935,7 @@
proname => 'box_div', prorettype => 'box', proargtypes => 'box point',
prosrc => 'box_div' },
{ oid => '1426',
- proname => 'path_contain_pt', prolang => 'sql', prorettype => 'bool',
+ proname => 'path_contain_pt', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'path point', prosrc => 'select pg_catalog.on_ppath($2, $1)' },
{ oid => '1428',
proname => 'poly_contain_pt', prorettype => 'bool',
@@ -3195,7 +3195,7 @@
proname => 'center', prorettype => 'point', proargtypes => 'circle',
prosrc => 'circle_center' },
{ oid => '1544', descr => 'convert circle to 12-vertex polygon',
- proname => 'polygon', prolang => 'sql', prorettype => 'polygon',
+ proname => 'polygon', prolang => 'pgsql', prorettype => 'polygon',
proargtypes => 'circle', prosrc => 'select pg_catalog.polygon(12, $1)' },
{ oid => '1545', descr => 'number of points',
proname => 'npoints', prorettype => 'int4', proargtypes => 'path',
@@ -3491,11 +3491,11 @@
proname => 'translate', prorettype => 'text', proargtypes => 'text text text',
prosrc => 'translate' },
{ oid => '879', descr => 'left-pad string to length',
- proname => 'lpad', prolang => 'sql', prorettype => 'text',
+ proname => 'lpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.lpad($1, $2, \' \')' },
{ oid => '880', descr => 'right-pad string to length',
- proname => 'rpad', prolang => 'sql', prorettype => 'text',
+ proname => 'rpad', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.rpad($1, $2, \' \')' },
{ oid => '881', descr => 'trim spaces from left end of string',
@@ -4086,7 +4086,7 @@
proname => 'inetpl', prorettype => 'inet', proargtypes => 'inet int8',
prosrc => 'inetpl' },
{ oid => '2631',
- proname => 'int8pl_inet', prolang => 'sql', prorettype => 'inet',
+ proname => 'int8pl_inet', prolang => 'pgsql', prorettype => 'inet',
proargtypes => 'int8 inet', prosrc => 'select $2 + $1' },
{ oid => '2632',
proname => 'inetmi_int8', prorettype => 'inet', proargtypes => 'inet int8',
@@ -4218,13 +4218,13 @@
proname => 'round', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_round' },
{ oid => '1708', descr => 'value rounded to \'scale\' of zero',
- proname => 'round', prolang => 'sql', prorettype => 'numeric',
+ proname => 'round', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.round($1,0)' },
{ oid => '1709', descr => 'value truncated to \'scale\'',
proname => 'trunc', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_trunc' },
{ oid => '1710', descr => 'value truncated to \'scale\' of zero',
- proname => 'trunc', prolang => 'sql', prorettype => 'numeric',
+ proname => 'trunc', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.trunc($1,0)' },
{ oid => '1711', descr => 'nearest integer >= value',
proname => 'ceil', prorettype => 'numeric', proargtypes => 'numeric',
@@ -4324,10 +4324,10 @@
proname => 'numeric', prorettype => 'numeric', proargtypes => 'int4',
prosrc => 'int4_numeric' },
{ oid => '1741', descr => 'base 10 logarithm',
- proname => 'log', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1481', descr => 'base 10 logarithm',
- proname => 'log10', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log10', prolang => 'pgsql', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1742', descr => 'convert float4 to numeric',
proname => 'numeric', prorettype => 'numeric', proargtypes => 'float4',
@@ -4460,7 +4460,7 @@
proname => 'quote_literal', prorettype => 'text', proargtypes => 'text',
prosrc => 'quote_literal' },
{ oid => '1285', descr => 'quote a data value for usage in a querystring',
- proname => 'quote_literal', prolang => 'sql', provolatile => 's',
+ proname => 'quote_literal', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_literal($1::pg_catalog.text)' },
{ oid => '1289',
@@ -4469,7 +4469,7 @@
proargtypes => 'text', prosrc => 'quote_nullable' },
{ oid => '1290',
descr => 'quote a possibly-null data value for usage in a querystring',
- proname => 'quote_nullable', prolang => 'sql', proisstrict => 'f',
+ proname => 'quote_nullable', prolang => 'pgsql', proisstrict => 'f',
provolatile => 's', prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_nullable($1::pg_catalog.text)' },
@@ -4508,13 +4508,13 @@
prorettype => 'text', proargtypes => 'text', prosrc => 'text_format_nv' },
{ oid => '1810', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bytea', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1811', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'text', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1812', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'pgsql', prorettype => 'int4',
proargtypes => 'bit', prosrc => 'select pg_catalog.length($1)' },
# Selectivity estimators for LIKE and related operators
@@ -4833,7 +4833,7 @@
prosrc => 'to_ascii_encname' },
{ oid => '1848',
- proname => 'interval_pl_time', prolang => 'sql', prorettype => 'time',
+ proname => 'interval_pl_time', prolang => 'pgsql', prorettype => 'time',
proargtypes => 'interval time', prosrc => 'select $2 + $1' },
{ oid => '1850',
@@ -5249,12 +5249,12 @@
proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
prosrc => 'pg_stat_get_wal_receiver' },
{ oid => '6118', descr => 'statistics: information about subscription',
- proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
+ proname => 'pg_stat_get_sub', proisstrict => 'f', provolatile => 's',
proparallel => 'r', prorettype => 'record', proargtypes => 'oid',
proallargtypes => '{oid,oid,oid,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}',
proargmodes => '{i,o,o,o,o,o,o,o,o}',
proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}',
- prosrc => 'pg_stat_get_subscription' },
+ prosrc => 'pg_stat_get_sub' },
{ oid => '2026', descr => 'statistics: current backend PID',
proname => 'pg_backend_pid', provolatile => 's', proparallel => 'r',
prorettype => 'int4', proargtypes => '', prosrc => 'pg_backend_pid' },
@@ -5663,11 +5663,11 @@
proargtypes => 'timetz int4', prosrc => 'timetz_scale' },
{ oid => '2003',
- proname => 'textanycat', prolang => 'sql', provolatile => 's',
+ proname => 'textanycat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'text anynonarray',
prosrc => 'select $1 || $2::pg_catalog.text' },
{ oid => '2004',
- proname => 'anytextcat', prolang => 'sql', provolatile => 's',
+ proname => 'anytextcat', prolang => 'pgsql', provolatile => 's',
prorettype => 'text', proargtypes => 'anynonarray text',
prosrc => 'select $1::pg_catalog.text || $2' },
@@ -5767,15 +5767,15 @@
proargtypes => 'timestamp timestamp timestamp timestamp',
prosrc => 'overlaps_timestamp' },
{ oid => '2042', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '2043', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp timestamp timestamp interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '2044', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'pgsql', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp timestamp',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
{ oid => '2045', descr => 'less-equal-greater',
@@ -5841,7 +5841,7 @@
proargtypes => 'timestamp timestamp', prosrc => 'timestamp_age' },
{ oid => '2059',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'pgsql', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamp',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp without time zone), $1)' },
@@ -5862,7 +5862,7 @@
proname => 'substring', prorettype => 'text', proargtypes => 'text text',
prosrc => 'textregexsubstr' },
{ oid => '2074', descr => 'extract text matching SQL regular expression',
- proname => 'substring', prolang => 'sql', prorettype => 'text',
+ proname => 'substring', prolang => 'pgsql', prorettype => 'text',
proargtypes => 'text text text',
prosrc => 'select pg_catalog.substring($1, pg_catalog.similar_to_escape($2, $3))' },
@@ -6201,11 +6201,11 @@
proname => 'pg_sleep', provolatile => 'v', prorettype => 'void',
proargtypes => 'float8', prosrc => 'pg_sleep' },
{ oid => '3935', descr => 'sleep for the specified interval',
- proname => 'pg_sleep_for', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_for', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'interval',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from pg_catalog.clock_timestamp() operator(pg_catalog.+) $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '3936', descr => 'sleep until the specified time',
- proname => 'pg_sleep_until', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_until', prolang => 'pgsql', provolatile => 'v',
prorettype => 'void', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '315', descr => 'Is JIT compilation available in this session?',
@@ -7016,7 +7016,7 @@
proargtypes => 'name', prosrc => 'pg_database_size_name' },
{ oid => '2325',
descr => 'disk space usage for the main fork of the specified table or index',
- proname => 'pg_relation_size', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_relation_size', prolang => 'pgsql', provolatile => 'v',
prorettype => 'int8', proargtypes => 'regclass',
prosrc => 'select pg_catalog.pg_relation_size($1, \'main\')' },
{ oid => '2332',
@@ -7898,21 +7898,21 @@
# formerly-missing interval + datetime operators
{ oid => '2546',
- proname => 'interval_pl_date', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'interval_pl_date', prolang => 'pgsql', prorettype => 'timestamp',
proargtypes => 'interval date', prosrc => 'select $2 + $1' },
{ oid => '2547',
- proname => 'interval_pl_timetz', prolang => 'sql', prorettype => 'timetz',
+ proname => 'interval_pl_timetz', prolang => 'pgsql', prorettype => 'timetz',
proargtypes => 'interval timetz', prosrc => 'select $2 + $1' },
{ oid => '2548',
- proname => 'interval_pl_timestamp', prolang => 'sql',
+ proname => 'interval_pl_timestamp', prolang => 'pgsql',
prorettype => 'timestamp', proargtypes => 'interval timestamp',
prosrc => 'select $2 + $1' },
{ oid => '2549',
- proname => 'interval_pl_timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'interval_pl_timestamptz', prolang => 'pgsql', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'interval timestamptz',
prosrc => 'select $2 + $1' },
{ oid => '2550',
- proname => 'integer_pl_date', prolang => 'sql', prorettype => 'date',
+ proname => 'integer_pl_date', prolang => 'pgsql', prorettype => 'date',
proargtypes => 'int4 date', prosrc => 'select $2 + $1' },
{ oid => '2556', descr => 'get OIDs of databases in a tablespace',
@@ -8301,7 +8301,7 @@
proname => 'xpath', prorettype => '_xml', proargtypes => 'text xml _text',
prosrc => 'xpath' },
{ oid => '2932', descr => 'evaluate XPath expression',
- proname => 'xpath', prolang => 'sql', prorettype => '_xml',
+ proname => 'xpath', prolang => 'pgsql', prorettype => '_xml',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath($1, $2, \'{}\'::pg_catalog.text[])' },
@@ -8314,7 +8314,7 @@
proname => 'xpath_exists', prorettype => 'bool',
proargtypes => 'text xml _text', prosrc => 'xpath_exists' },
{ oid => '3050', descr => 'test XML value against XPath expression',
- proname => 'xpath_exists', prolang => 'sql', prorettype => 'bool',
+ proname => 'xpath_exists', prolang => 'pgsql', prorettype => 'bool',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '3051', descr => 'determine if a string is well formed XML',
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_sub.h
similarity index 88%
rename from src/include/catalog/pg_subscription.h
rename to src/include/catalog/pg_sub.h
index 0a756d42d8..4faf0aa370 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_sub.h
@@ -1,12 +1,12 @@
/* -------------------------------------------------------------------------
*
- * pg_subscription.h
+ * pg_sub.h
* definition of the "subscription" system catalog (pg_subscription)
*
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * src/include/catalog/pg_subscription.h
+ * src/include/catalog/pg_sub.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
@@ -18,7 +18,7 @@
#define PG_SUBSCRIPTION_H
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_d.h"
+#include "catalog/pg_sub_d.h"
#include "nodes/pg_list.h"
@@ -36,7 +36,7 @@
*
* NOTE: When adding a column, also update system_views.sql.
*/
-CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
+CATALOG(pg_sub,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
@@ -45,12 +45,12 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
Oid subowner; /* Owner of the subscription */
- bool subenabled; /* True if the subscription is enabled (the
+ bool subactive; /* True if the subscription is enabled (the
* worker should be running) */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
/* Connection string to the publisher */
- text subconninfo BKI_FORCE_NOT_NULL;
+ text subconn BKI_FORCE_NOT_NULL;
/* Slot name on publisher */
NameData subslotname;
diff --git a/src/include/catalog/toasting.h b/src/include/catalog/toasting.h
index 51491c4513..5372bf88a1 100644
--- a/src/include/catalog/toasting.h
+++ b/src/include/catalog/toasting.h
@@ -95,7 +95,7 @@ DECLARE_TOAST(pg_shdescription, 2846, 2847);
DECLARE_TOAST(pg_shseclabel, 4060, 4061);
#define PgShseclabelToastTable 4060
#define PgShseclabelToastIndex 4061
-DECLARE_TOAST(pg_subscription, 4183, 4184);
+DECLARE_TOAST(pg_sub, 4183, 4184);
#define PgSubscriptionToastTable 4183
#define PgSubscriptionToastIndex 4184
DECLARE_TOAST(pg_tablespace, 4185, 4186);
diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h
index 8ed7e45056..8d913cffe3 100644
--- a/src/include/replication/worker_internal.h
+++ b/src/include/replication/worker_internal.h
@@ -15,7 +15,7 @@
#include <signal.h>
#include "access/xlogdefs.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
On Thu, Jun 11, 2020 at 07:58:43PM +0300, Anastasia Lubennikova wrote:
I would be glad to add some test, but it seems to me that the infrastructure
changes for cross-version pg_upgrade test is much more complicated task than
this modest bugfix. Besides, I've read the discussion and it seems that
Michael
is not going to continue this work.
The main issue I recall from this patch series was the lack of
enthusiasm because it would break potential users running major
upgrade tests based on test.sh. At the same time, if you don't break
the wheel..
Attached v10 patch contains more fix for uninitialized variable.
Thanks. Sorry for the time it takes. I'd like to get into this issue
but I have not been able to dive into it seriously yet.
--
Michael
Tested this patch by running several upgrades from different major
versions and different setups.
ACL, that are impossible to apply, are detected and reported, so it
looks good for me.
On Thu, Jun 11, 2020 at 07:58:43PM +0300, Anastasia Lubennikova wrote:
On 08.06.2020 19:31, Alvaro Herrera wrote:
I'm thinking what's a good way to have a test that's committable. Maybe
it would work to add a TAP test to pg_upgrade that runs initdb, does a
few GRANTS as per your attachment, then runs pg_upgrade? Currently the
pg_upgrade tests are not TAP ... we'd have to revive
/messages/by-id/20180126080026.GI17847@paquier.xyz
(Some progress was already made on the buildfarm front to permit this)I would be glad to add some test, but it seems to me that the infrastructure
changes for cross-version pg_upgrade test is much more complicated task than
this modest bugfix.
Agreed.
--- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c
+static void +check_for_changed_signatures(void) +{
+ snprintf(output_path, sizeof(output_path), "revoke_objects.sql");
If an upgrade deleted function pg_last_wal_replay_lsn, upgrading a database in
which "REVOKE ALL ON FUNCTION pg_last_wal_replay_lsn FROM public" happened
requires a GRANT. Can you use a file name that will still make sense if
someone enhances pg_upgrade to generate such GRANT statements?
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) + pg_fatal("could not open file \"%s\": %s\n", + output_path, strerror(errno));
Use %m instead of passing sterror(errno) to %s.
+ } + + /* Handle columns separately */ + if (strstr(aclinfo->obj_type, "column") != NULL) + { + char *pdot = last_dot_location(aclinfo->obj_ident);
I'd write strrchr(aclinfo->obj_ident, '.') instead of introducing
last_dot_location().
This assumes column names don't contain '.'; how difficult would it be to
remove that assumption? If it's difficult, a cheap approach would be to
ignore any entry containing too many dots. We're not likely to create such
column names at initdb time, but v13 does allow:
ALTER VIEW pg_locks RENAME COLUMN objid TO "a.b";
GRANT SELECT ("a.b") ON pg_locks TO backup;
After which revoke_objects.sql has:
psql:./revoke_objects.sql:9: ERROR: syntax error at or near "") ON pg_catalog.pg_locks.""
LINE 1: REVOKE ALL (b") ON pg_catalog.pg_locks."a FROM "backup";
While that ALTER VIEW probably should have required allow_system_table_mods,
we need to assume such databases exist.
--- a/src/bin/pg_upgrade/info.c +++ b/src/bin/pg_upgrade/info.c
+get_non_default_acl_infos(ClusterInfo *cluster) +{
+ res = executeQueryOrDie(conn, + /* + * Get relations, attributes, functions and procedures. Some system + * objects like views are not pinned, but these type of objects are + * created in pg_catalog schema. + */ + "SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, " + " CASE WHEN shd.classid = 'pg_class'::regclass THEN true " + " ELSE false " + " END is_relation " + "FROM pg_catalog.pg_shdepend shd, " + "LATERAL pg_catalog.pg_identify_object(" + " shd.classid, shd.objid, shd.objsubid) obj " + /* 'a' is for SHARED_DEPENDENCY_ACL */ + "WHERE shd.deptype = 'a' AND shd.dbid = %d " + " AND shd.classid IN ('pg_proc'::regclass, 'pg_class'::regclass) " + /* get only system objects */ + " AND obj.schema = 'pg_catalog' "
Overall, this patch predicts a subset of cases where pg_dump will emit a
failing GRANT or REVOKE that targets a pg_catalog object. Can you write a
code comment stating what it does and does not detect? I think it's okay to
not predict every failure, but let's record the intended coverage. Here are a
few examples I know; there may be more. The above query only finds GRANTs to
non-pinned roles. pg_dump dumps the following, but the above query doesn't
find them:
REVOKE ALL ON FUNCTION pg_last_wal_replay_lsn FROM public;
GRANT EXECUTE ON FUNCTION pg_reload_conf() TO pg_signal_backend;
The above query should test refclassid.
This function should not run queries against servers older than 9.6, because
pg_dump emits GRANT/REVOKE for pg_catalog objects only when targeting 9.6 or
later. An upgrade from 8.4 to master is failing on the above query:
===
Checking for large objects ok
SQL command failed
SELECT obj.type, obj.identity, shd.refobjid::regrole rolename, CASE WHEN shd.classid = 'pg_class'::regclass THEN true ELSE false END is_relation FROM pg_catalog.pg_shdepend shd, LATERAL pg_catalog.pg_identify_object( shd.classid, shd.objid, shd.objsubid) obj WHERE shd.deptype = 'a' AND shd.dbid = 11564 AND shd.classid IN ('pg_proc'::regclass, 'pg_class'::regclass) AND obj.schema = 'pg_catalog' ORDER BY obj.identity COLLATE "C";
ERROR: syntax error at or near "."
LINE 1: ...ROM pg_catalog.pg_shdepend shd, LATERAL pg_catalog.pg_identi...
^
Failure, exiting
===
+ while (aclnum < PQntuples(res) && + strcmp(curr->obj_ident, PQgetvalue(res, aclnum, i_obj_ident)) == 0)
The patch adds many lines wider than 78 columns, this being one example. In
general, break such lines. (Don't break string literal arguments of
ereport(), though.)
nm
On 03.01.2021 14:29, Noah Misch wrote:
On Thu, Jun 11, 2020 at 07:58:43PM +0300, Anastasia Lubennikova wrote:
On 08.06.2020 19:31, Alvaro Herrera wrote:
I'm thinking what's a good way to have a test that's committable. Maybe
it would work to add a TAP test to pg_upgrade that runs initdb, does a
few GRANTS as per your attachment, then runs pg_upgrade? Currently the
pg_upgrade tests are not TAP ... we'd have to revive
/messages/by-id/20180126080026.GI17847@paquier.xyz
(Some progress was already made on the buildfarm front to permit this)I would be glad to add some test, but it seems to me that the infrastructure
changes for cross-version pg_upgrade test is much more complicated task than
this modest bugfix.Agreed.
Thank you for the review.
New version of the patch is attached, though I haven't tested it
properly yet. I am planning to do in a couple of days.
--- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c +static void +check_for_changed_signatures(void) +{ + snprintf(output_path, sizeof(output_path), "revoke_objects.sql");If an upgrade deleted function pg_last_wal_replay_lsn, upgrading a database in
which "REVOKE ALL ON FUNCTION pg_last_wal_replay_lsn FROM public" happened
requires a GRANT. Can you use a file name that will still make sense if
someone enhances pg_upgrade to generate such GRANT statements?
I changed the name to 'fix_system_objects_ACL.sql'. Does it look good to
you?
+ if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL) + pg_fatal("could not open file \"%s\": %s\n", + output_path, strerror(errno));Use %m instead of passing sterror(errno) to %s.
Done.
+ } + + /* Handle columns separately */ + if (strstr(aclinfo->obj_type, "column") != NULL) + { + char *pdot = last_dot_location(aclinfo->obj_ident);I'd write strrchr(aclinfo->obj_ident, '.') instead of introducing
last_dot_location().This assumes column names don't contain '.'; how difficult would it be to
remove that assumption? If it's difficult, a cheap approach would be to
ignore any entry containing too many dots. We're not likely to create such
column names at initdb time, but v13 does allow:ALTER VIEW pg_locks RENAME COLUMN objid TO "a.b";
GRANT SELECT ("a.b") ON pg_locks TO backup;After which revoke_objects.sql has:
psql:./revoke_objects.sql:9: ERROR: syntax error at or near "") ON pg_catalog.pg_locks.""
LINE 1: REVOKE ALL (b") ON pg_catalog.pg_locks."a FROM "backup";While that ALTER VIEW probably should have required allow_system_table_mods,
we need to assume such databases exist.
I've fixed it by using pg_identify_object_as_address(). Now we don't
have to parse obj_identity.
Overall, this patch predicts a subset of cases where pg_dump will emit a
failing GRANT or REVOKE that targets a pg_catalog object. Can you write a
code comment stating what it does and does not detect? I think it's okay to
not predict every failure, but let's record the intended coverage. Here are a
few examples I know; there may be more. The above query only finds GRANTs to
non-pinned roles. pg_dump dumps the following, but the above query doesn't
find them:REVOKE ALL ON FUNCTION pg_last_wal_replay_lsn FROM public;
GRANT EXECUTE ON FUNCTION pg_reload_conf() TO pg_signal_backend;The above query should test refclassid.
This function should not run queries against servers older than 9.6, because
pg_dump emits GRANT/REVOKE for pg_catalog objects only when targeting 9.6 or
later. An upgrade from 8.4 to master is failing on the above query:
Fixed.
The patch adds many lines wider than 78 columns, this being one example. In
general, break such lines. (Don't break string literal arguments of
ereport(), though.)
Fixed.
nm
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v11.patchtext/x-patch; charset=UTF-8; name=pg_upgrade_ACL_check_v11.patchDownload
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 43fc297eb6..429e4468f2 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -151,6 +152,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -170,6 +173,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -328,6 +332,249 @@ check_cluster_compatibility(bool live_check)
"the old and new port numbers must be different.\n");
}
+/*
+ * check_for_changed_signatures()
+ *
+ * Check that the old cluster doesn't have non-default ACL's for system
+ * objects, which have different signatures in the new cluster,
+ * because they can cause failure during pg_restore stage of
+ * the upgrade process.
+ *
+ * If such objects exist generate fix_system_objects_ACL.sql script
+ * to adjust ACLs before upgrade.
+ *
+ * Currently supported object types are
+ * - table, view, sequence
+ * - table column, view column
+ * - procedure, function, aggregate
+ * - language
+ * - type, domain.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ char subquery[QUERY_ALLOC];
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 906)
+ return;
+
+ prep_status("Checking for system objects with non-default ACL");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+
+ /*
+ * The old cluster doesn't have system objects with non-default ACL,
+ * so exit quickly.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "fix_system_objects_ACL.sql");
+
+ conn = connectToServer(&new_cluster, "template1");
+
+
+ /* Gather the list of system objects' identities in a new cluster */
+
+ snprintf(subquery, sizeof(subquery),
+ /* Get system relations */
+ "SELECT 'pg_class'::regclass classid, oid objid, 0 objsubid "
+ "FROM pg_catalog.pg_class "
+ "WHERE relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system table columns, view columns */
+ "SELECT 'pg_class'::regclass, att.attrelid, att.attnum "
+ "FROM pg_catalog.pg_class rel "
+ "INNER JOIN pg_catalog.pg_attribute att ON rel.oid = att.attrelid "
+ "WHERE rel.relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system functions and procedures */
+ "SELECT 'pg_proc'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_proc "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system languages */
+ "SELECT 'pg_language'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_language "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system types and domains */
+ "SELECT 'pg_type'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_type "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace "
+ );
+
+ res = executeQueryOrDie(conn,
+ "SELECT ident.type, ident.identity "
+ "FROM (%s) obj, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " obj.classid, obj.objid, obj.objsubid) ident "
+ /*
+ * Don't rely on database collation, since we use strcmp
+ * comparison to find non-default ACLs.
+ */
+ "ORDER BY ident.identity COLLATE \"C\";", subquery);
+
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ /* For every database check system objects with non-default ACL. */
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool report = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(aclinfo->obj_ident,
+ PQgetvalue(res, objnum, i_obj_ident));
+
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ {
+ report = true;
+ break;
+ }
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ objnum++;
+ break;
+ }
+ else
+ objnum++;
+ }
+
+ /* Generate REVOKE statemets for the found objects */
+ if (report)
+ {
+ found_changed = true;
+ if (script == NULL &&
+ (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %m\n", output_path);
+
+ /* append connect database command */
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+ /* Handle table column objects */
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ {
+ char *name_pos = strstr(aclinfo->obj_ident,
+ aclinfo->obj_name);
+ PQExpBufferData ident_buf;
+
+ if (name_pos == NULL)
+ pg_fatal("invalid column identity \"%s\"",
+ aclinfo->obj_ident);
+
+ //DEBUG
+ pg_fatal("\n aclinfo->obj_ident = %s, aclinfo->obj_name = %s, name_pos = %s",
+ aclinfo->obj_ident, aclinfo->obj_name, name_pos);
+ if (*name_pos == '\"')
+ name_pos--;
+
+ initPQExpBuffer(&ident_buf);
+ appendBinaryPQExpBuffer(&ident_buf, aclinfo->obj_ident,
+ name_pos - aclinfo->obj_ident);
+
+ fprintf(script, "REVOKE ALL (%s) ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_name, ident_buf.data,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ termPQExpBuffer(&ident_buf);
+ }
+ /*
+ * For relations except sequences we don't need to specify
+ * the object type.
+ */
+ else if (aclinfo->is_relation &&
+ strcmp(aclinfo->obj_type, "sequence") != 0)
+ fprintf(script, "REVOKE ALL ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ /* Other object types */
+ else
+ fprintf(script, "REVOKE ALL ON %s %s FROM %s;\n",
+ aclinfo->obj_type,
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* check_locale_and_encoding()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 5d9a26cf82..2a93f4bb94 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,131 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Fill AclInfo array with information about system objects that
+ * have non-default ACL.
+ *
+ * Currently supported object types are
+ * - table, view, sequence
+ * - table column, view column
+ * - procedure, function, aggregate
+ * - language
+ * - type, domain.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos = NULL;
+ AclInfo *curr = NULL;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_obj_name,
+ i_rolname,
+ i_is_relation;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get system objects with non-default ACLs.
+ */
+ "SELECT obj.type, obj.identity, "
+ " obj_as_address.object_names[array_length(object_names, 1)] "
+ " as name, shd.refobjid::regrole rolename, "
+ " CASE WHEN shd.classid = 'pg_class'::regclass THEN true "
+ " ELSE false "
+ " END is_relation "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj, "
+ " pg_catalog.pg_identify_object_as_address("
+ " shd.classid, shd.objid, shd.objsubid) obj_as_address "
+ /* 'a' is for SHARED_DEPENDENCY_ACL */
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid IN ('pg_proc'::regclass, "
+ " 'pg_class'::regclass, 'pg_language'::regclass, "
+ " 'pg_language'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ * Don't rely on database collation, since we use strcmp
+ * comparison below.
+ */
+ "ORDER BY obj.identity COLLATE \"C\";", dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_obj_name = PQfnumber(res, "name");
+ i_rolname = PQfnumber(res, "rolename");
+ i_is_relation = PQfnumber(res, "is_relation");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBuffer roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+ curr->obj_name = pg_strdup(PQgetvalue(res, aclnum, i_obj_name));
+ curr->is_relation =
+ PQgetvalue(res, aclnum, i_is_relation)[0] == 't';
+
+ roles_buf = createPQExpBuffer();
+ initPQExpBuffer(roles_buf);
+
+ /*
+ * For each object gather string of role names mentioned in ACL
+ * in a format convenient for further use
+ * in GRANT/REVOKE statement.
+ */
+ while (aclnum < PQntuples(res) &&
+ strcmp(curr->obj_ident,
+ PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf->len != 0)
+ appendPQExpBufferChar(roles_buf, ',');
+
+ appendPQExpBufferStr(roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+
+ curr->role_names = pg_strdup(roles_buf->data);
+ destroyPQExpBuffer(roles_buf);
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -384,6 +511,10 @@ get_db_infos(ClusterInfo *cluster)
dbinfos[tupnum].db_ctype = pg_strdup(PQgetvalue(res, tupnum, i_datctype));
snprintf(dbinfos[tupnum].db_tablespace, sizeof(dbinfos[tupnum].db_tablespace), "%s",
PQgetvalue(res, tupnum, i_spclocation));
+
+ /* initialize clean array */
+ dbinfos[tupnum].non_def_acl_arr.nacls = 0;
+ dbinfos[tupnum].non_def_acl_arr.aclinfos = NULL;
}
PQclear(res);
@@ -595,6 +726,9 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+
+ if (&db_arr->dbs[dbnum].non_def_acl_arr.nacls > 0)
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +754,23 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+
+ pg_free(acl_arr->aclinfos);
+ acl_arr->aclinfos = NULL;
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 919a7849fd..aca1d357cc 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -147,6 +147,29 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Information about database object needed to check
+ * if its signature has changed between versions
+ * and generate REVOKE statement if necessary.
+ */
+typedef struct
+{
+ char *obj_type; /* object type */
+ char *obj_ident; /* complete object identity */
+ char *obj_name; /* object name
+ * store it separately from identity
+ * to simplify parsing */
+ bool is_relation; /* if the object is relation */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -183,6 +206,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -389,6 +414,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
On Thu, Jan 21, 2021 at 01:03:58AM +0300, Anastasia Lubennikova wrote:
On 03.01.2021 14:29, Noah Misch wrote:
On Thu, Jun 11, 2020 at 07:58:43PM +0300, Anastasia Lubennikova wrote:
Thank you for the review.
New version of the patch is attached, though I haven't tested it properly
yet. I am planning to do in a couple of days.
Once that testing completes, please change the commitfest entry status to
Ready for Committer.
+ snprintf(output_path, sizeof(output_path), "revoke_objects.sql");
If an upgrade deleted function pg_last_wal_replay_lsn, upgrading a database in
which "REVOKE ALL ON FUNCTION pg_last_wal_replay_lsn FROM public" happened
requires a GRANT. Can you use a file name that will still make sense if
someone enhances pg_upgrade to generate such GRANT statements?I changed the name to 'fix_system_objects_ACL.sql'. Does it look good to
you?
That name is fine with me.
ALTER VIEW pg_locks RENAME COLUMN objid TO "a.b";
GRANT SELECT ("a.b") ON pg_locks TO backup;After which revoke_objects.sql has:
psql:./revoke_objects.sql:9: ERROR: syntax error at or near "") ON pg_catalog.pg_locks.""
LINE 1: REVOKE ALL (b") ON pg_catalog.pg_locks."a FROM "backup";While that ALTER VIEW probably should have required allow_system_table_mods,
we need to assume such databases exist.I've fixed it by using pg_identify_object_as_address(). Now we don't have to
parse obj_identity.
Nice.
On 21.01.2021 07:07, Noah Misch wrote:
On Thu, Jun 11, 2020 at 07:58:43PM +0300, Anastasia Lubennikova wrote:
Thank you for the review.
New version of the patch is attached, though I haven't tested it properly
yet. I am planning to do in a couple of days.Once that testing completes, please change the commitfest entry status to
Ready for Committer.
New version is attached along with a test script.
To use it, you can simply run pg_upgrade_ACL_test.sh script in a
directory that contains postrges git repository. See comments in the file.
The test includes patch to rename several system objects.
Renamed objects are the following:
- table pg_subscription -> pg_sub
- columns pg_subscription.subenabled -> subactive,
- view pg_stat_subscription -> pg_stat_sub
pg_stat_subscription.latest_end_lsn -> latest_end_location
- function pg_stat_get_subscription -> pg_stat_get_sub
- language sql -> pgsql
Compared to v11, I fixed a couple of minor issues and removed language
support.
It seems unlikely, that we will ever change language signature, which
consist of language name only.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v12.patchtext/x-patch; charset=UTF-8; name=pg_upgrade_ACL_check_v12.patchDownload
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 43fc297eb6..87204b567b 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -151,6 +152,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -170,6 +173,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -328,6 +332,240 @@ check_cluster_compatibility(bool live_check)
"the old and new port numbers must be different.\n");
}
+/*
+ * check_for_changed_signatures()
+ *
+ * Check that the old cluster doesn't have non-default ACL's for system
+ * objects, which have different signatures in the new cluster,
+ * because they can cause failure during pg_restore stage of
+ * the upgrade process.
+ *
+ * If such objects exist generate fix_system_objects_ACL.sql script
+ * to adjust ACLs before upgrade.
+ *
+ * Currently supported object types are
+ * - table, view, sequence
+ * - table column, view column
+ * - procedure, function, aggregate
+ * - type, domain.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ char subquery[QUERY_ALLOC];
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 906)
+ return;
+
+ prep_status("Checking for system objects with non-default ACL");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+
+ /*
+ * The old cluster doesn't have system objects with non-default ACL,
+ * so exit quickly.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "fix_system_objects_ACL.sql");
+
+ conn = connectToServer(&new_cluster, "template1");
+
+
+ /* Gather the list of system objects' identities in a new cluster */
+
+ snprintf(subquery, sizeof(subquery),
+ /* Get system relations */
+ "SELECT 'pg_class'::regclass classid, oid objid, 0 objsubid "
+ "FROM pg_catalog.pg_class "
+ "WHERE relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system table columns, view columns */
+ "SELECT 'pg_class'::regclass, att.attrelid, att.attnum "
+ "FROM pg_catalog.pg_class rel "
+ "INNER JOIN pg_catalog.pg_attribute att ON rel.oid = att.attrelid "
+ "WHERE rel.relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system functions and procedures */
+ "SELECT 'pg_proc'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_proc "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system types and domains */
+ "SELECT 'pg_type'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_type "
+ "WHERE typnamespace = 'pg_catalog'::regnamespace "
+ );
+
+ res = executeQueryOrDie(conn,
+ "SELECT ident.type, ident.identity "
+ "FROM (%s) obj, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " obj.classid, obj.objid, obj.objsubid) ident "
+ /*
+ * Don't rely on database collation, since we use strcmp
+ * comparison to find non-default ACLs.
+ */
+ "ORDER BY ident.identity COLLATE \"C\";", subquery);
+
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ /* For every database check system objects with non-default ACL. */
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool report = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(aclinfo->obj_ident,
+ PQgetvalue(res, objnum, i_obj_ident));
+
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ {
+ report = true;
+ break;
+ }
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ objnum++;
+ break;
+ }
+ else
+ objnum++;
+ }
+
+ /* Generate REVOKE statemets for the found objects */
+ if (report)
+ {
+ found_changed = true;
+ if (script == NULL &&
+ (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %m\n", output_path);
+
+ /* append connect database command */
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+ /* Handle table column objects */
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ {
+ char *name_pos = strstr(aclinfo->obj_ident,
+ aclinfo->obj_name);
+ PQExpBufferData ident_buf;
+
+ if (name_pos == NULL)
+ pg_fatal("invalid column identity \"%s\"",
+ aclinfo->obj_ident);
+
+ if (*name_pos == '\"')
+ name_pos--;
+
+ initPQExpBuffer(&ident_buf);
+ appendBinaryPQExpBuffer(&ident_buf, aclinfo->obj_ident,
+ name_pos - aclinfo->obj_ident - 1);
+
+ fprintf(script, "REVOKE ALL (%s) ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_name, ident_buf.data,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ termPQExpBuffer(&ident_buf);
+ }
+ /*
+ * For relations except sequences we don't need to specify
+ * the object type.
+ */
+ else if (aclinfo->is_relation &&
+ strcmp(aclinfo->obj_type, "sequence") != 0)
+ fprintf(script, "REVOKE ALL ON %s FROM %s;\n",
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ /* Other object types */
+ else
+ fprintf(script, "REVOKE ALL ON %s %s FROM %s;\n",
+ aclinfo->obj_type,
+ /* pg_identify_object() quotes identity if necessary */
+ aclinfo->obj_ident,
+ /* role_names is already quoted */
+ aclinfo->role_names);
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* check_locale_and_encoding()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 5d9a26cf82..a4ea3cbe34 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,129 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Fill AclInfo array with information about system objects that
+ * have non-default ACL.
+ *
+ * Currently supported object types are
+ * - table, view, sequence
+ * - table column, view column
+ * - procedure, function, aggregate
+ * - type, domain.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos = NULL;
+ AclInfo *curr = NULL;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_obj_name,
+ i_rolname,
+ i_is_relation;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get system objects with non-default ACLs.
+ */
+ "SELECT obj.type, obj.identity, "
+ " obj_as_address.object_names[array_length(object_names, 1)] "
+ " as name, shd.refobjid::regrole rolename, "
+ " CASE WHEN shd.classid = 'pg_class'::regclass THEN true "
+ " ELSE false "
+ " END is_relation "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj, "
+ " pg_catalog.pg_identify_object_as_address("
+ " shd.classid, shd.objid, shd.objsubid) obj_as_address "
+ /* 'a' is for SHARED_DEPENDENCY_ACL */
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.classid IN ('pg_proc'::regclass, "
+ " 'pg_class'::regclass, 'pg_type'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ * Don't rely on database collation, since we use strcmp
+ * comparison below.
+ */
+ "ORDER BY obj.identity COLLATE \"C\";", dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_obj_name = PQfnumber(res, "name");
+ i_rolname = PQfnumber(res, "rolename");
+ i_is_relation = PQfnumber(res, "is_relation");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBuffer roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+ curr->obj_name = pg_strdup(PQgetvalue(res, aclnum, i_obj_name));
+ curr->is_relation =
+ PQgetvalue(res, aclnum, i_is_relation)[0] == 't';
+
+ roles_buf = createPQExpBuffer();
+ initPQExpBuffer(roles_buf);
+
+ /*
+ * For each object gather string of role names mentioned in ACL
+ * in a format convenient for further use
+ * in GRANT/REVOKE statement.
+ */
+ while (aclnum < PQntuples(res) &&
+ strcmp(curr->obj_ident,
+ PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf->len != 0)
+ appendPQExpBufferChar(roles_buf, ',');
+
+ appendPQExpBufferStr(roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+
+ curr->role_names = pg_strdup(roles_buf->data);
+ destroyPQExpBuffer(roles_buf);
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -384,6 +509,10 @@ get_db_infos(ClusterInfo *cluster)
dbinfos[tupnum].db_ctype = pg_strdup(PQgetvalue(res, tupnum, i_datctype));
snprintf(dbinfos[tupnum].db_tablespace, sizeof(dbinfos[tupnum].db_tablespace), "%s",
PQgetvalue(res, tupnum, i_spclocation));
+
+ /* initialize clean array */
+ dbinfos[tupnum].non_def_acl_arr.nacls = 0;
+ dbinfos[tupnum].non_def_acl_arr.aclinfos = NULL;
}
PQclear(res);
@@ -595,6 +724,9 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+
+ if (&db_arr->dbs[dbnum].non_def_acl_arr.nacls > 0)
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +752,23 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+
+ pg_free(acl_arr->aclinfos);
+ acl_arr->aclinfos = NULL;
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 919a7849fd..aca1d357cc 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -147,6 +147,29 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Information about database object needed to check
+ * if its signature has changed between versions
+ * and generate REVOKE statement if necessary.
+ */
+typedef struct
+{
+ char *obj_type; /* object type */
+ char *obj_ident; /* complete object identity */
+ char *obj_name; /* object name
+ * store it separately from identity
+ * to simplify parsing */
+ bool is_relation; /* if the object is relation */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -183,6 +206,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -389,6 +414,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
test_rename_catalog_objects_v12text/plain; charset=UTF-8; name=test_rename_catalog_objects_v12Download
commit 5d58c1372fa737832106919d87f68d7ad793df51
Author: anastasia <a.lubennikova@postgrespro.ru>
Date: Thu Jan 21 17:16:51 2021 +0300
test_rename_catalog_objects_v11
diff --git a/contrib/ptrack b/contrib/ptrack
new file mode 160000
index 0000000000..c6c19ed121
--- /dev/null
+++ b/contrib/ptrack
@@ -0,0 +1 @@
+Subproject commit c6c19ed121019cc7a980229f2da14beb85c4f4a3
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index c85f0ca7b6..dc5ef06b7f 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -40,7 +40,7 @@ OBJS = \
pg_publication.o \
pg_range.o \
pg_shdepend.o \
- pg_subscription.o \
+ pg_sub.o \
pg_type.o \
storage.o \
toasting.o
@@ -67,8 +67,8 @@ CATALOG_HEADERS := \
pg_foreign_table.h pg_policy.h pg_replication_origin.h \
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
- pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
- pg_subscription_rel.h
+ pg_sequence.h pg_publication.h pg_publication_rel.h pg_sub.h \
+ pg_sub_rel.h
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 1a81e768ec..6b5663961d 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -50,7 +50,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
@@ -5248,7 +5248,7 @@ pg_publication_ownercheck(Oid pub_oid, Oid roleid)
* Ownership check for a subscription (specified by OID).
*/
bool
-pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
+pg_sub_ownercheck(Oid sub_oid, Oid roleid)
{
HeapTuple tuple;
Oid ownerId;
@@ -5263,7 +5263,7 @@ pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription with OID %u does not exist", sub_oid)));
- ownerId = ((Form_pg_subscription) GETSTRUCT(tuple))->subowner;
+ ownerId = ((Form_pg_sub) GETSTRUCT(tuple))->subowner;
ReleaseSysCache(tuple);
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index e2ed80a5de..95257d5db7 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -36,7 +36,7 @@
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 2140151a6a..0dcb701a69 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 9abc4a1f55..f03f25bd56 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -56,7 +56,7 @@
#include "catalog/pg_opclass.h"
#include "catalog/pg_partitioned_table.h"
#include "catalog/pg_statistic.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/storage.h"
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 4907855043..aef3bf7f03 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -42,7 +42,7 @@ SET search_path TO information_schema;
/* Expand any 1-D array into a set with integers 1..N */
CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
RETURNS SETOF RECORD
- LANGUAGE sql STRICT IMMUTABLE PARALLEL SAFE
+ LANGUAGE sqltest STRICT IMMUTABLE PARALLEL SAFE
AS 'select $1[s], s - pg_catalog.array_lower($1,1) + 1
from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
pg_catalog.array_upper($1,1),
@@ -51,7 +51,7 @@ CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
/* Given an index's OID and an underlying-table column number, return the
* column's position in the index (NULL if not there) */
CREATE FUNCTION _pg_index_position(oid, smallint) RETURNS int
- LANGUAGE sql STRICT STABLE
+ LANGUAGE sqltest STRICT STABLE
AS $$
SELECT (ss.a).n FROM
(SELECT information_schema._pg_expandarray(indkey) AS a
@@ -60,7 +60,7 @@ SELECT (ss.a).n FROM
$$;
CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -68,7 +68,7 @@ CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
$$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typbasetype ELSE $1.atttypid END$$;
CREATE FUNCTION _pg_truetypmod(pg_attribute, pg_type) RETURNS int4
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -78,7 +78,7 @@ $$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typtypmod ELSE $1.atttypmod END$$;
-- these functions encapsulate knowledge about the encoding of typmod:
CREATE FUNCTION _pg_char_max_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -94,7 +94,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_char_octet_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -110,7 +110,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -131,7 +131,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision_radix(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -143,7 +143,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_scale(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -159,7 +159,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_datetime_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -175,7 +175,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_interval_type(typid oid, mod int4) RETURNS text
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -1477,7 +1477,7 @@ CREATE VIEW routines AS
CAST(null AS cardinal_number) AS maximum_cardinality,
CAST(CASE WHEN p.prokind <> 'p' THEN 0 END AS sql_identifier) AS dtd_identifier,
- CAST(CASE WHEN l.lanname = 'sql' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
+ CAST(CASE WHEN l.lanname = 'sqltest' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
AS routine_body,
CAST(
CASE WHEN pg_has_role(p.proowner, 'USAGE') THEN p.prosrc ELSE null END
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 6d88b690d8..dfd2a4128f 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
@@ -579,10 +579,10 @@ static const ObjectPropertyType ObjectProperty[] =
SubscriptionObjectIndexId,
SUBSCRIPTIONOID,
SUBSCRIPTIONNAME,
- Anum_pg_subscription_oid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_oid,
+ Anum_pg_sub_subname,
InvalidAttrNumber,
- Anum_pg_subscription_subowner,
+ Anum_pg_sub_subowner,
InvalidAttrNumber,
OBJECT_SUBSCRIPTION,
true
@@ -2510,7 +2510,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
strVal((Value *) object));
break;
case OBJECT_SUBSCRIPTION:
- if (!pg_subscription_ownercheck(address.objectId, roleid))
+ if (!pg_sub_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
strVal((Value *) object));
break;
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 90b7a5de29..8e2bd02dcb 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -40,7 +40,7 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_sub.c
similarity index 83%
rename from src/backend/catalog/pg_subscription.c
rename to src/backend/catalog/pg_sub.c
index 44cb285b68..669975641d 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_sub.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
- * pg_subscription.c
+ * pg_sub.c
* replication subscriptions
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * src/backend/catalog/pg_subscription.c
+ * src/backend/catalog/pg_sub.c
*
*-------------------------------------------------------------------------
*/
@@ -20,8 +20,8 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/indexing.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
@@ -43,7 +43,7 @@ GetSubscription(Oid subid, bool missing_ok)
{
HeapTuple tup;
Subscription *sub;
- Form_pg_subscription subform;
+ Form_pg_sub subform;
Datum datum;
bool isnull;
@@ -57,21 +57,21 @@ GetSubscription(Oid subid, bool missing_ok)
elog(ERROR, "cache lookup failed for subscription %u", subid);
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = (Form_pg_sub) GETSTRUCT(tup);
sub = (Subscription *) palloc(sizeof(Subscription));
sub->oid = subid;
sub->dbid = subform->subdbid;
sub->name = pstrdup(NameStr(subform->subname));
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->binary = subform->subbinary;
sub->stream = subform->substream;
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subconninfo,
+ Anum_pg_sub_subconninfo,
&isnull);
Assert(!isnull);
sub->conninfo = TextDatumGetCString(datum);
@@ -79,7 +79,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subslotname,
+ Anum_pg_sub_subslotname,
&isnull);
if (!isnull)
sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));
@@ -89,7 +89,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get synccommit */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subsynccommit,
+ Anum_pg_sub_subsynccommit,
&isnull);
Assert(!isnull);
sub->synccommit = TextDatumGetCString(datum);
@@ -97,7 +97,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get publications */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subpublications,
+ Anum_pg_sub_subpublications,
&isnull);
Assert(!isnull);
sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
@@ -123,7 +123,7 @@ CountDBSubscriptions(Oid dbid)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- Anum_pg_subscription_subdbid,
+ Anum_pg_sub_subdbid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
@@ -165,7 +165,7 @@ get_subscription_oid(const char *subname, bool missing_ok)
{
Oid oid;
- oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(subname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
@@ -185,7 +185,7 @@ get_subscription_name(Oid subid, bool missing_ok)
{
HeapTuple tup;
char *subname;
- Form_pg_subscription subform;
+ Form_pg_sub subform;
tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
@@ -196,7 +196,7 @@ get_subscription_name(Oid subid, bool missing_ok)
return NULL;
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = (Form_pg_sub) GETSTRUCT(tup);
subname = pstrdup(NameStr(subform->subname));
ReleaseSysCache(tup);
@@ -239,8 +239,8 @@ AddSubscriptionRelState(Oid subid, Oid relid, char state,
{
Relation rel;
HeapTuple tup;
- bool nulls[Natts_pg_subscription_rel];
- Datum values[Natts_pg_subscription_rel];
+ bool nulls[Natts_pg_sub_rel];
+ Datum values[Natts_pg_sub_rel];
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
@@ -257,13 +257,13 @@ AddSubscriptionRelState(Oid subid, Oid relid, char state,
/* Form the tuple. */
memset(values, 0, sizeof(values));
memset(nulls, false, sizeof(nulls));
- values[Anum_pg_subscription_rel_srsubid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_rel_srrelid - 1] = ObjectIdGetDatum(relid);
- values[Anum_pg_subscription_rel_srsubstate - 1] = CharGetDatum(state);
+ values[Anum_pg_sub_rel_srsubid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_rel_srrelid - 1] = ObjectIdGetDatum(relid);
+ values[Anum_pg_sub_rel_srsubstate - 1] = CharGetDatum(state);
if (sublsn != InvalidXLogRecPtr)
- values[Anum_pg_subscription_rel_srsublsn - 1] = LSNGetDatum(sublsn);
+ values[Anum_pg_sub_rel_srsublsn - 1] = LSNGetDatum(sublsn);
else
- nulls[Anum_pg_subscription_rel_srsublsn - 1] = true;
+ nulls[Anum_pg_sub_rel_srsublsn - 1] = true;
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -285,9 +285,9 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
{
Relation rel;
HeapTuple tup;
- bool nulls[Natts_pg_subscription_rel];
- Datum values[Natts_pg_subscription_rel];
- bool replaces[Natts_pg_subscription_rel];
+ bool nulls[Natts_pg_sub_rel];
+ Datum values[Natts_pg_sub_rel];
+ bool replaces[Natts_pg_sub_rel];
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
@@ -306,14 +306,14 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
memset(nulls, false, sizeof(nulls));
memset(replaces, false, sizeof(replaces));
- replaces[Anum_pg_subscription_rel_srsubstate - 1] = true;
- values[Anum_pg_subscription_rel_srsubstate - 1] = CharGetDatum(state);
+ replaces[Anum_pg_sub_rel_srsubstate - 1] = true;
+ values[Anum_pg_sub_rel_srsubstate - 1] = CharGetDatum(state);
- replaces[Anum_pg_subscription_rel_srsublsn - 1] = true;
+ replaces[Anum_pg_sub_rel_srsublsn - 1] = true;
if (sublsn != InvalidXLogRecPtr)
- values[Anum_pg_subscription_rel_srsublsn - 1] = LSNGetDatum(sublsn);
+ values[Anum_pg_sub_rel_srsublsn - 1] = LSNGetDatum(sublsn);
else
- nulls[Anum_pg_subscription_rel_srsublsn - 1] = true;
+ nulls[Anum_pg_sub_rel_srsublsn - 1] = true;
tup = heap_modify_tuple(tup, RelationGetDescr(rel), values, nulls,
replaces);
@@ -350,11 +350,11 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
}
/* Get the state. */
- substate = ((Form_pg_subscription_rel) GETSTRUCT(tup))->srsubstate;
+ substate = ((Form_pg_sub_rel) GETSTRUCT(tup))->srsubstate;
/* Get the LSN */
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
- Anum_pg_subscription_rel_srsublsn, &isnull);
+ Anum_pg_sub_rel_srsublsn, &isnull);
if (isnull)
*sublsn = InvalidXLogRecPtr;
else
@@ -384,7 +384,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
if (OidIsValid(subid))
{
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srsubid,
BTEqualStrategyNumber,
F_OIDEQ,
ObjectIdGetDatum(subid));
@@ -393,7 +393,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
if (OidIsValid(relid))
{
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srrelid,
+ Anum_pg_sub_rel_srrelid,
BTEqualStrategyNumber,
F_OIDEQ,
ObjectIdGetDatum(relid));
@@ -429,7 +429,7 @@ GetSubscriptionRelations(Oid subid)
rel = table_open(SubscriptionRelRelationId, AccessShareLock);
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srsubid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(subid));
@@ -438,18 +438,18 @@ GetSubscriptionRelations(Oid subid)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_subscription_rel subrel;
+ Form_pg_sub_rel subrel;
SubscriptionRelState *relstate;
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = (Form_pg_sub_rel) GETSTRUCT(tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
- Anum_pg_subscription_rel_srsublsn, &isnull);
+ Anum_pg_sub_rel_srsublsn, &isnull);
if (isnull)
relstate->lsn = InvalidXLogRecPtr;
else
@@ -483,12 +483,12 @@ GetSubscriptionNotReadyRelations(Oid subid)
rel = table_open(SubscriptionRelRelationId, AccessShareLock);
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srsubid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(subid));
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubstate,
+ Anum_pg_sub_rel_srsubstate,
BTEqualStrategyNumber, F_CHARNE,
CharGetDatum(SUBREL_STATE_READY));
@@ -497,18 +497,18 @@ GetSubscriptionNotReadyRelations(Oid subid)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_subscription_rel subrel;
+ Form_pg_sub_rel subrel;
SubscriptionRelState *relstate;
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = (Form_pg_sub_rel) GETSTRUCT(tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
- Anum_pg_subscription_rel_srsublsn, &isnull);
+ Anum_pg_sub_rel_srsublsn, &isnull);
if (isnull)
relstate->lsn = InvalidXLogRecPtr;
else
diff --git a/src/backend/catalog/sql_features.txt b/src/backend/catalog/sql_features.txt
index caa971c435..59e028e168 100644
--- a/src/backend/catalog/sql_features.txt
+++ b/src/backend/catalog/sql_features.txt
@@ -28,7 +28,7 @@ B124 Routine language Fortran NO
B125 Routine language MUMPS NO
B126 Routine language Pascal NO
B127 Routine language PL/I NO
-B128 Routine language SQL NO
+B128 Routine LANGUAGE SQLTEST NO
B200 Polymorphic table functions NO
B201 More than one PTF generic table parameter NO
B202 PTF Copartitioning NO
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index fa58afd9d7..6eb18cbde2 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -478,7 +478,7 @@ SELECT
l.provider, l.label
FROM
pg_shseclabel l
- JOIN pg_subscription s ON l.classoid = s.tableoid AND l.objoid = s.oid
+ JOIN pg_sub s ON l.classoid = s.tableoid AND l.objoid = s.oid
UNION ALL
SELECT
l.objoid, l.classoid, 0::int4 AS objsubid,
@@ -832,7 +832,7 @@ CREATE VIEW pg_stat_wal_receiver AS
s.received_tli,
s.last_msg_send_time,
s.last_msg_receipt_time,
- s.latest_end_lsn,
+ s.latest_end_location,
s.latest_end_time,
s.slot_name,
s.sender_host,
@@ -841,7 +841,7 @@ CREATE VIEW pg_stat_wal_receiver AS
FROM pg_stat_get_wal_receiver() s
WHERE s.pid IS NOT NULL;
-CREATE VIEW pg_stat_subscription AS
+CREATE VIEW pg_stat_sub AS
SELECT
su.oid AS subid,
su.subname,
@@ -850,10 +850,10 @@ CREATE VIEW pg_stat_subscription AS
st.received_lsn,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_location,
st.latest_end_time
- FROM pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL) st
+ FROM pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL) st
ON (st.subid = su.oid);
CREATE VIEW pg_stat_ssl AS
@@ -1165,10 +1165,10 @@ CREATE VIEW pg_replication_origin_status AS
REVOKE ALL ON pg_replication_origin_status FROM public;
--- All columns of pg_subscription except subconninfo are readable.
-REVOKE ALL ON pg_subscription FROM public;
-GRANT SELECT (subdbid, subname, subowner, subenabled, subbinary, substream, subslotname, subpublications)
- ON pg_subscription TO public;
+-- All columns of pg_sub except subconninfo are readable.
+REVOKE ALL ON pg_sub FROM public;
+GRANT SELECT (subdbid, subname, subowner, subactive, subbinary, substream, subslotname, subpublications)
+ ON pg_sub TO public;
--
@@ -1218,7 +1218,7 @@ FROM pg_catalog.ts_parse(
) AS tt
WHERE tt.tokid = parse.tokid
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE SQLTEST STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(regconfig,text) IS
'debug function for text search configuration';
@@ -1234,7 +1234,7 @@ RETURNS SETOF record AS
$$
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1);
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE SQLTEST STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(text) IS
'debug function for current text search configuration';
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 29249498a9..6f3d7fc23c 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -35,7 +35,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 2b159b60eb..e44c3b7a97 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -38,7 +38,7 @@
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 082f7855b8..8b368baa96 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -23,8 +23,8 @@
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h"
@@ -345,8 +345,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
Relation rel;
ObjectAddress myself;
Oid subid;
- bool nulls[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
Oid owner = GetUserId();
HeapTuple tup;
bool connect;
@@ -407,7 +407,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Check if name is used */
- subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(stmt->subname));
if (OidIsValid(subid))
{
@@ -438,25 +438,25 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
memset(nulls, false, sizeof(nulls));
subid = GetNewOidWithIndex(rel, SubscriptionObjectIndexId,
- Anum_pg_subscription_oid);
- values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
- values[Anum_pg_subscription_subname - 1] =
+ Anum_pg_sub_oid);
+ values[Anum_pg_sub_oid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
+ values[Anum_pg_sub_subname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
- values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
- values[Anum_pg_subscription_subenabled - 1] = BoolGetDatum(enabled);
- values[Anum_pg_subscription_subbinary - 1] = BoolGetDatum(binary);
- values[Anum_pg_subscription_substream - 1] = BoolGetDatum(streaming);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subowner - 1] = ObjectIdGetDatum(owner);
+ values[Anum_pg_sub_subactive - 1] = BoolGetDatum(enabled);
+ values[Anum_pg_sub_subbinary - 1] = BoolGetDatum(binary);
+ values[Anum_pg_sub_substream - 1] = BoolGetDatum(streaming);
+ values[Anum_pg_sub_subconninfo - 1] =
CStringGetTextDatum(conninfo);
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- values[Anum_pg_subscription_subsynccommit - 1] =
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(publications);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -670,14 +670,14 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
{
Relation rel;
ObjectAddress myself;
- bool nulls[Natts_pg_subscription];
- bool replaces[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ bool replaces[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
HeapTuple tup;
Oid subid;
bool update_tuple = false;
Subscription *sub;
- Form_pg_subscription form;
+ Form_pg_sub form;
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
@@ -691,11 +691,11 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
errmsg("subscription \"%s\" does not exist",
stmt->subname)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
subid = form->oid;
/* must be owner */
- if (!pg_subscription_ownercheck(subid, GetUserId()))
+ if (!pg_sub_ownercheck(subid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
stmt->subname);
@@ -741,32 +741,32 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
"slot_name = NONE")));
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- replaces[Anum_pg_subscription_subslotname - 1] = true;
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ replaces[Anum_pg_sub_subslotname - 1] = true;
}
if (synchronous_commit)
{
- values[Anum_pg_subscription_subsynccommit - 1] =
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- replaces[Anum_pg_subscription_subsynccommit - 1] = true;
+ replaces[Anum_pg_sub_subsynccommit - 1] = true;
}
if (binary_given)
{
- values[Anum_pg_subscription_subbinary - 1] =
+ values[Anum_pg_sub_subbinary - 1] =
BoolGetDatum(binary);
- replaces[Anum_pg_subscription_subbinary - 1] = true;
+ replaces[Anum_pg_sub_subbinary - 1] = true;
}
if (streaming_given)
{
- values[Anum_pg_subscription_substream - 1] =
+ values[Anum_pg_sub_substream - 1] =
BoolGetDatum(streaming);
- replaces[Anum_pg_subscription_substream - 1] = true;
+ replaces[Anum_pg_sub_substream - 1] = true;
}
update_tuple = true;
@@ -795,9 +795,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot enable subscription that does not have a slot name")));
- values[Anum_pg_subscription_subenabled - 1] =
+ values[Anum_pg_sub_subactive - 1] =
BoolGetDatum(enabled);
- replaces[Anum_pg_subscription_subenabled - 1] = true;
+ replaces[Anum_pg_sub_subactive - 1] = true;
if (enabled)
ApplyLauncherWakeupAtCommit();
@@ -812,9 +812,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
/* Check the connection info string. */
walrcv_check_conninfo(stmt->conninfo);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subconninfo - 1] =
CStringGetTextDatum(stmt->conninfo);
- replaces[Anum_pg_subscription_subconninfo - 1] = true;
+ replaces[Anum_pg_sub_subconninfo - 1] = true;
update_tuple = true;
break;
@@ -833,9 +833,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
&refresh,
NULL, NULL, /* no "binary" */
NULL, NULL); /* no "streaming" */
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(stmt->publication);
- replaces[Anum_pg_subscription_subpublications - 1] = true;
+ replaces[Anum_pg_sub_subpublications - 1] = true;
update_tuple = true;
@@ -929,10 +929,10 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
RepOriginId originid;
WalReceiverConn *wrconn = NULL;
StringInfoData cmd;
- Form_pg_subscription form;
+ Form_pg_sub form;
/*
- * Lock pg_subscription with AccessExclusiveLock to ensure that the
+ * Lock pg_sub with AccessExclusiveLock to ensure that the
* launcher doesn't restart new worker during dropping the subscription
*/
rel = table_open(SubscriptionRelationId, AccessExclusiveLock);
@@ -957,11 +957,11 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
return;
}
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
subid = form->oid;
/* must be owner */
- if (!pg_subscription_ownercheck(subid, GetUserId()))
+ if (!pg_sub_ownercheck(subid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
stmt->subname);
@@ -976,19 +976,19 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
/* Get subname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subname, &isnull);
+ Anum_pg_sub_subname, &isnull);
Assert(!isnull);
subname = pstrdup(NameStr(*DatumGetName(datum)));
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subconninfo, &isnull);
+ Anum_pg_sub_subconninfo, &isnull);
Assert(!isnull);
conninfo = TextDatumGetCString(datum);
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subslotname, &isnull);
+ Anum_pg_sub_subslotname, &isnull);
if (!isnull)
slotname = pstrdup(NameStr(*DatumGetName(datum)));
else
@@ -1118,14 +1118,14 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
static void
AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
- Form_pg_subscription form;
+ Form_pg_sub form;
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
if (form->subowner == newOwnerId)
return;
- if (!pg_subscription_ownercheck(form->oid, GetUserId()))
+ if (!pg_sub_ownercheck(form->oid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
NameStr(form->subname));
@@ -1159,7 +1159,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
HeapTuple tup;
Relation rel;
ObjectAddress address;
- Form_pg_subscription form;
+ Form_pg_sub form;
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
@@ -1171,7 +1171,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription \"%s\" does not exist", name)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
subid = form->oid;
AlterSubscriptionOwner_internal(rel, tup, newOwnerId);
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 186514cd9e..8dc6e852f9 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -22,8 +22,8 @@
#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "funcapi.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
@@ -95,7 +95,7 @@ static void logicalrep_worker_cleanup(LogicalRepWorker *worker);
static bool on_commit_launcher_wakeup = false;
-Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
+Datum pg_stat_get_sub(PG_FUNCTION_ARGS);
/*
@@ -135,7 +135,7 @@ get_subscription_list(void)
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
- Form_pg_subscription subform = (Form_pg_subscription) GETSTRUCT(tup);
+ Form_pg_sub subform = (Form_pg_sub) GETSTRUCT(tup);
Subscription *sub;
MemoryContext oldcxt;
@@ -151,7 +151,7 @@ get_subscription_list(void)
sub->oid = subform->oid;
sub->dbid = subform->subdbid;
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->name = pstrdup(NameStr(subform->subname));
/* We don't fill fields we are not interested in. */
@@ -927,7 +927,7 @@ AtEOSubXact_ApplyLauncher(bool isCommit, int nestDepth)
*
* This is used to send launcher signal to stop sleeping and process the
* subscriptions when current transaction commits. Should be used when new
- * tuple was added to the pg_subscription catalog.
+ * tuple was added to the pg_sub catalog.
*/
void
ApplyLauncherWakeupAtCommit(void)
@@ -966,7 +966,7 @@ ApplyLauncherMain(Datum main_arg)
/*
* Establish connection to nailed catalogs (we only ever access
- * pg_subscription).
+ * pg_sub).
*/
BackgroundWorkerInitializeConnection(NULL, NULL, 0);
@@ -1072,7 +1072,7 @@ IsLogicalLauncher(void)
* Returns state of the subscriptions.
*/
Datum
-pg_stat_get_subscription(PG_FUNCTION_ARGS)
+pg_stat_get_sub(PG_FUNCTION_ARGS)
{
#define PG_STAT_GET_SUBSCRIPTION_COLS 8
Oid subid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index e861c0ff80..997a535f0f 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -20,7 +20,7 @@
#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/namespace.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub_rel.h"
#include "executor/executor.h"
#include "nodes/makefuncs.h"
#include "replication/logicalrelation.h"
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 863d196fd7..5be56c80a4 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -51,7 +51,7 @@
* So the state progression is always: INIT -> DATASYNC -> SYNCWAIT ->
* CATCHUP -> SYNCDONE -> READY.
*
- * The catalog pg_subscription_rel is used to keep information about
+ * The catalog pg_sub_rel is used to keep information about
* subscribed tables and their state. Some transient state during data
* synchronization is kept in shared memory. The states SYNCWAIT and
* CATCHUP only appear in memory.
@@ -92,7 +92,7 @@
#include "access/table.h"
#include "access/xact.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_type.h"
#include "commands/copy.h"
#include "miscadmin.h"
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index f2b2549a51..76593b878a 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -65,8 +65,8 @@
#include "catalog/namespace.h"
#include "catalog/partition.h"
#include "catalog/pg_inherits.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_tablespace.h"
#include "commands/tablecmds.h"
#include "commands/tablespace.h"
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 723f513d8b..899af845b5 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1311,7 +1311,7 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
TimeLineID received_tli;
TimestampTz last_send_time;
TimestampTz last_receipt_time;
- XLogRecPtr latest_end_lsn;
+ XLogRecPtr latest_end_location;
TimestampTz latest_end_time;
char sender_host[NI_MAXHOST];
int sender_port = 0;
@@ -1330,7 +1330,7 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
received_tli = WalRcv->receivedTLI;
last_send_time = WalRcv->lastMsgSendTime;
last_receipt_time = WalRcv->lastMsgReceiptTime;
- latest_end_lsn = WalRcv->latestWalEnd;
+ latest_end_location = WalRcv->latestWalEnd;
latest_end_time = WalRcv->latestWalEndTime;
strlcpy(slotname, (char *) WalRcv->slotname, sizeof(slotname));
strlcpy(sender_host, (char *) WalRcv->sender_host, sizeof(sender_host));
@@ -1390,10 +1390,10 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
nulls[8] = true;
else
values[8] = TimestampTzGetDatum(last_receipt_time);
- if (XLogRecPtrIsInvalid(latest_end_lsn))
+ if (XLogRecPtrIsInvalid(latest_end_location))
nulls[9] = true;
else
- values[9] = LSNGetDatum(latest_end_lsn);
+ values[9] = LSNGetDatum(latest_end_location);
if (latest_end_time == 0)
nulls[10] = true;
else
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..eb60f2cfb8 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -60,7 +60,7 @@
#include "catalog/pg_rewrite.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
@@ -115,7 +115,7 @@ static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_
static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
-static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_subscription] = {Schema_pg_subscription};
+static const FormData_pg_attribute Desc_pg_sub[Natts_pg_sub] = {Schema_pg_sub};
/*
* Hash tables that index the relation cache
@@ -3845,8 +3845,8 @@ RelationCacheInitializePhase2(void)
Natts_pg_auth_members, Desc_pg_auth_members);
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
Natts_pg_shseclabel, Desc_pg_shseclabel);
- formrdesc("pg_subscription", SubscriptionRelation_Rowtype_Id, true,
- Natts_pg_subscription, Desc_pg_subscription);
+ formrdesc("pg_sub", SubscriptionRelation_Rowtype_Id, true,
+ Natts_pg_sub, Desc_pg_sub);
#define NUM_CRITICAL_SHARED_RELS 5 /* fix if you change list above */
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index e4dc4ee34e..a012f77f9b 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -62,8 +62,8 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
@@ -787,8 +787,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionNameIndexId,
2,
{
- Anum_pg_subscription_subdbid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_subdbid,
+ Anum_pg_sub_subname,
0,
0
},
@@ -798,7 +798,7 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionObjectIndexId,
1,
{
- Anum_pg_subscription_oid,
+ Anum_pg_sub_oid,
0,
0,
0
@@ -809,8 +809,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionRelSrrelidSrsubidIndexId,
2,
{
- Anum_pg_subscription_rel_srrelid,
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srrelid,
+ Anum_pg_sub_rel_srsubid,
0,
0
},
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index 60d306e7c3..00743ead8e 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -46,7 +46,7 @@ static void AddAcl(PQExpBuffer aclbuf, const char *keyword,
* remoteVersion: version of database
*
* Returns true if okay, false if could not parse the acl string.
- * The resulting commands (if any) are appended to the contents of 'sql'.
+ * The resulting commands (if any) are appended to the contents of 'sqltest'.
*
* Note: when processing a default ACL, prefix is "ALTER DEFAULT PRIVILEGES "
* or something similar, and name is an empty string.
@@ -378,7 +378,7 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
* remoteVersion: version of database
*
* Returns true if okay, false if could not parse the acl string.
- * The resulting commands (if any) are appended to the contents of 'sql'.
+ * The resulting commands (if any) are appended to the contents of 'sqltest'.
*/
bool
buildDefaultACLCommands(const char *type, const char *nspname,
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 798d14580e..d0d0ec7077 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4244,7 +4244,7 @@ getSubscriptions(Archive *fout)
int n;
res = ExecuteSqlQuery(fout,
- "SELECT count(*) FROM pg_subscription "
+ "SELECT count(*) FROM pg_sub "
"WHERE subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getSubscriptions(Archive *fout)
appendPQExpBufferStr(query, " false AS substream\n");
appendPQExpBufferStr(query,
- "FROM pg_subscription s\n"
+ "FROM pg_sub s\n"
"WHERE s.subdbid = (SELECT oid FROM pg_database\n"
" WHERE datname = current_database())");
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 2b501166b8..684350a123 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -1867,10 +1867,10 @@ my %tests = (
'CREATE FUNCTION ... SUPPORT' => {
create_order => 41,
create_sql =>
- 'CREATE FUNCTION dump_test.func_with_support() RETURNS int LANGUAGE sql AS $$ SELECT 1 $$ SUPPORT varchar_support;',
+ 'CREATE FUNCTION dump_test.func_with_support() RETURNS int LANGUAGE sqltest AS $$ SELECT 1 $$ SUPPORT varchar_support;',
regexp => qr/^
\QCREATE FUNCTION dump_test.func_with_support() RETURNS integer\E
- \n\s+\QLANGUAGE sql SUPPORT varchar_support\E
+ \n\s+\QLANGUAGE sqltest SUPPORT varchar_support\E
\n\s+AS\ \$\$\Q SELECT 1 \E\$\$;
/xm,
like =>
@@ -1881,10 +1881,10 @@ my %tests = (
'CREATE PROCEDURE dump_test.ptest1' => {
create_order => 41,
create_sql => 'CREATE PROCEDURE dump_test.ptest1(a int)
- LANGUAGE SQL AS $$ INSERT INTO dump_test.test_table (col1) VALUES (a) $$;',
+ LANGUAGE SQLTEST AS $$ INSERT INTO dump_test.test_table (col1) VALUES (a) $$;',
regexp => qr/^
\QCREATE PROCEDURE dump_test.ptest1(a integer)\E
- \n\s+\QLANGUAGE sql\E
+ \n\s+\QLANGUAGE sqltest\E
\n\s+AS\ \$\$\Q INSERT INTO dump_test.test_table (col1) VALUES (a) \E\$\$;
/xm,
like =>
@@ -1987,9 +1987,9 @@ my %tests = (
'CREATE TRANSFORM FOR int' => {
create_order => 34,
create_sql =>
- 'CREATE TRANSFORM FOR int LANGUAGE SQL (FROM SQL WITH FUNCTION prsd_lextype(internal), TO SQL WITH FUNCTION int4recv(internal));',
+ 'CREATE TRANSFORM FOR int LANGUAGE SQLTEST (FROM SQL WITH FUNCTION prsd_lextype(internal), TO SQL WITH FUNCTION int4recv(internal));',
regexp =>
- qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog\.prsd_lextype\(internal\), TO SQL WITH FUNCTION pg_catalog\.int4recv\(internal\)\);/m,
+ qr/CREATE TRANSFORM FOR integer LANGUAGE sqltest \(FROM SQL WITH FUNCTION pg_catalog\.prsd_lextype\(internal\), TO SQL WITH FUNCTION pg_catalog\.int4recv\(internal\)\);/m,
like => { %full_runs, section_pre_data => 1, },
},
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index caf97563f4..fbc85d2341 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -6005,7 +6005,7 @@ describeSubscriptions(const char *pattern, bool verbose)
printfPQExpBuffer(&buf,
"SELECT subname AS \"%s\"\n"
", pg_catalog.pg_get_userbyid(subowner) AS \"%s\"\n"
- ", subenabled AS \"%s\"\n"
+ ", subactive AS \"%s\"\n"
", subpublications AS \"%s\"\n",
gettext_noop("Name"),
gettext_noop("Owner"),
@@ -6031,7 +6031,7 @@ describeSubscriptions(const char *pattern, bool verbose)
/* Only display subscriptions in current database. */
appendPQExpBufferStr(&buf,
- "FROM pg_catalog.pg_subscription\n"
+ "FROM pg_catalog.pg_sub\n"
"WHERE subdbid = (SELECT oid\n"
" FROM pg_catalog.pg_database\n"
" WHERE datname = pg_catalog.current_database())");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 6abcbea963..a94328fbea 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -999,7 +999,7 @@ static const VersionedQuery Query_for_list_of_publications[] = {
static const VersionedQuery Query_for_list_of_subscriptions[] = {
{100000,
" SELECT pg_catalog.quote_ident(s.subname) "
- " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d "
+ " FROM pg_catalog.pg_sub s, pg_catalog.pg_database d "
" WHERE substring(pg_catalog.quote_ident(s.subname),1,%d)='%s' "
" AND d.datname = pg_catalog.current_database() "
" AND s.subdbid = d.oid"
diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl
index 9e36b6d2b0..37bd088e9e 100644
--- a/src/bin/scripts/t/100_vacuumdb.pl
+++ b/src/bin/scripts/t/100_vacuumdb.pl
@@ -88,8 +88,8 @@ $node->safe_psql(
CREATE TABLE vactable (a int, b int);
CREATE VIEW vacview AS SELECT 1 as a;
- CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQL AS 'SELECT $1 * $1';
- CREATE FUNCTION f1(int) RETURNS int LANGUAGE SQL AS 'SELECT f0($1)';
+ CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQLTEST AS 'SELECT $1 * $1';
+ CREATE FUNCTION f1(int) RETURNS int LANGUAGE SQLTEST AS 'SELECT f0($1)';
CREATE TABLE funcidx (x int);
INSERT INTO funcidx VALUES (0),(1),(2),(3);
CREATE INDEX i0 ON funcidx ((f1(x)));
diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h
index f272e2c99f..06c6128183 100644
--- a/src/include/catalog/dependency.h
+++ b/src/include/catalog/dependency.h
@@ -131,7 +131,7 @@ typedef enum ObjectClass
OCLASS_POLICY, /* pg_policy */
OCLASS_PUBLICATION, /* pg_publication */
OCLASS_PUBLICATION_REL, /* pg_publication_rel */
- OCLASS_SUBSCRIPTION, /* pg_subscription */
+ OCLASS_SUBSCRIPTION, /* pg_sub */
OCLASS_TRANSFORM /* pg_transform */
} ObjectClass;
diff --git a/src/include/catalog/pg_language.dat b/src/include/catalog/pg_language.dat
index a584679927..88f710f9f0 100644
--- a/src/include/catalog/pg_language.dat
+++ b/src/include/catalog/pg_language.dat
@@ -20,6 +20,6 @@
lanname => 'c', lanvalidator => 'fmgr_c_validator' },
{ oid => '14', oid_symbol => 'SQLlanguageId',
descr => 'SQL-language functions',
- lanname => 'sql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
+ lanname => 'sqltest', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
]
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index dd64c3bd60..ab9f66e703 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2350,7 +2350,7 @@
proname => 'justify_days', prorettype => 'interval',
proargtypes => 'interval', prosrc => 'interval_justify_days' },
{ oid => '1176', descr => 'convert date and time to timestamp with time zone',
- proname => 'timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'timestamptz', prolang => 'sqltest', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'date time',
prosrc => 'select cast(($1 + $2) as timestamp with time zone)' },
{ oid => '1178', descr => 'convert timestamp with time zone to date',
@@ -2403,16 +2403,16 @@
prosrc => 'interval_scale' },
{ oid => '1215', descr => 'get description for object id and catalog name',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0' },
{ oid => '1216', descr => 'get description for table column',
- proname => 'col_description', prolang => 'sql', procost => '100',
+ proname => 'col_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'pg_catalog.pg_class\'::pg_catalog.regclass and objsubid = $2' },
{ oid => '1993',
descr => 'get description for object id and shared catalog name',
- proname => 'shobj_description', prolang => 'sql', procost => '100',
+ proname => 'shobj_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP)' },
@@ -2585,13 +2585,13 @@
prosrc => 'hashtidextended' },
{ oid => '1296',
- proname => 'timedate_pl', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'timedate_pl', prolang => 'sqltest', prorettype => 'timestamp',
proargtypes => 'time date', prosrc => 'select ($2 + $1)' },
{ oid => '1297',
proname => 'datetimetz_pl', prorettype => 'timestamptz',
proargtypes => 'date timetz', prosrc => 'datetimetz_timestamptz' },
{ oid => '1298',
- proname => 'timetzdate_pl', prolang => 'sql', prorettype => 'timestamptz',
+ proname => 'timetzdate_pl', prolang => 'sqltest', prorettype => 'timestamptz',
proargtypes => 'timetz date', prosrc => 'select ($2 + $1)' },
{ oid => '1299', descr => 'current transaction time',
proname => 'now', provolatile => 's', prorettype => 'timestamptz',
@@ -2633,17 +2633,17 @@
proargtypes => 'timestamptz timestamptz timestamptz timestamptz',
prosrc => 'overlaps_timestamp' },
{ oid => '1305', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1306', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz timestamptz timestamptz interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1307', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz timestamptz',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2652,15 +2652,15 @@
proname => 'overlaps', proisstrict => 'f', prorettype => 'bool',
proargtypes => 'time time time time', prosrc => 'overlaps_time' },
{ oid => '1309', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1310', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time time time interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1311', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time time',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2741,7 +2741,7 @@
# This form of obj_description is now deprecated, since it will fail if
# OIDs are not unique across system catalogs. Use the other form instead.
{ oid => '1348', descr => 'deprecated, use two-argument form instead',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and objsubid = 0' },
@@ -2825,7 +2825,7 @@
prosrc => 'textlen' },
{ oid => '1384', descr => 'extract field from date',
- proname => 'date_part', prolang => 'sql', prorettype => 'float8',
+ proname => 'date_part', prolang => 'sqltest', prorettype => 'float8',
proargtypes => 'text date',
prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time zone))' },
{ oid => '1385', descr => 'extract field from time',
@@ -2833,7 +2833,7 @@
prosrc => 'time_part' },
{ oid => '1386',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'sqltest', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp with time zone), $1)' },
@@ -2948,7 +2948,7 @@
proname => 'box_div', prorettype => 'box', proargtypes => 'box point',
prosrc => 'box_div' },
{ oid => '1426',
- proname => 'path_contain_pt', prolang => 'sql', prorettype => 'bool',
+ proname => 'path_contain_pt', prolang => 'sqltest', prorettype => 'bool',
proargtypes => 'path point', prosrc => 'select pg_catalog.on_ppath($2, $1)' },
{ oid => '1428',
proname => 'poly_contain_pt', prorettype => 'bool',
@@ -3208,7 +3208,7 @@
proname => 'center', prorettype => 'point', proargtypes => 'circle',
prosrc => 'circle_center' },
{ oid => '1544', descr => 'convert circle to 12-vertex polygon',
- proname => 'polygon', prolang => 'sql', prorettype => 'polygon',
+ proname => 'polygon', prolang => 'sqltest', prorettype => 'polygon',
proargtypes => 'circle', prosrc => 'select pg_catalog.polygon(12, $1)' },
{ oid => '1545', descr => 'number of points',
proname => 'npoints', prorettype => 'int4', proargtypes => 'path',
@@ -3504,11 +3504,11 @@
proname => 'translate', prorettype => 'text', proargtypes => 'text text text',
prosrc => 'translate' },
{ oid => '879', descr => 'left-pad string to length',
- proname => 'lpad', prolang => 'sql', prorettype => 'text',
+ proname => 'lpad', prolang => 'sqltest', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.lpad($1, $2, \' \')' },
{ oid => '880', descr => 'right-pad string to length',
- proname => 'rpad', prolang => 'sql', prorettype => 'text',
+ proname => 'rpad', prolang => 'sqltest', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.rpad($1, $2, \' \')' },
{ oid => '881', descr => 'trim spaces from left end of string',
@@ -4102,7 +4102,7 @@
proname => 'inetpl', prorettype => 'inet', proargtypes => 'inet int8',
prosrc => 'inetpl' },
{ oid => '2631',
- proname => 'int8pl_inet', prolang => 'sql', prorettype => 'inet',
+ proname => 'int8pl_inet', prolang => 'sqltest', prorettype => 'inet',
proargtypes => 'int8 inet', prosrc => 'select $2 + $1' },
{ oid => '2632',
proname => 'inetmi_int8', prorettype => 'inet', proargtypes => 'inet int8',
@@ -4234,13 +4234,13 @@
proname => 'round', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_round' },
{ oid => '1708', descr => 'value rounded to \'scale\' of zero',
- proname => 'round', prolang => 'sql', prorettype => 'numeric',
+ proname => 'round', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.round($1,0)' },
{ oid => '1709', descr => 'value truncated to \'scale\'',
proname => 'trunc', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_trunc' },
{ oid => '1710', descr => 'value truncated to \'scale\' of zero',
- proname => 'trunc', prolang => 'sql', prorettype => 'numeric',
+ proname => 'trunc', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.trunc($1,0)' },
{ oid => '1711', descr => 'nearest integer >= value',
proname => 'ceil', prorettype => 'numeric', proargtypes => 'numeric',
@@ -4340,10 +4340,10 @@
proname => 'numeric', proleakproof => 't', prorettype => 'numeric',
proargtypes => 'int4', prosrc => 'int4_numeric' },
{ oid => '1741', descr => 'base 10 logarithm',
- proname => 'log', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1481', descr => 'base 10 logarithm',
- proname => 'log10', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log10', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1742', descr => 'convert float4 to numeric',
proname => 'numeric', proleakproof => 't', prorettype => 'numeric',
@@ -4479,7 +4479,7 @@
proname => 'quote_literal', prorettype => 'text', proargtypes => 'text',
prosrc => 'quote_literal' },
{ oid => '1285', descr => 'quote a data value for usage in a querystring',
- proname => 'quote_literal', prolang => 'sql', provolatile => 's',
+ proname => 'quote_literal', prolang => 'sqltest', provolatile => 's',
prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_literal($1::pg_catalog.text)' },
{ oid => '1289',
@@ -4488,7 +4488,7 @@
proargtypes => 'text', prosrc => 'quote_nullable' },
{ oid => '1290',
descr => 'quote a possibly-null data value for usage in a querystring',
- proname => 'quote_nullable', prolang => 'sql', proisstrict => 'f',
+ proname => 'quote_nullable', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_nullable($1::pg_catalog.text)' },
@@ -4527,13 +4527,13 @@
prorettype => 'text', proargtypes => 'text', prosrc => 'text_format_nv' },
{ oid => '1810', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'sqltest', prorettype => 'int4',
proargtypes => 'bytea', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1811', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'sqltest', prorettype => 'int4',
proargtypes => 'text', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1812', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'sqltest', prorettype => 'int4',
proargtypes => 'bit', prosrc => 'select pg_catalog.length($1)' },
# Selectivity estimators for LIKE and related operators
@@ -4852,7 +4852,7 @@
prosrc => 'to_ascii_encname' },
{ oid => '1848',
- proname => 'interval_pl_time', prolang => 'sql', prorettype => 'time',
+ proname => 'interval_pl_time', prolang => 'sqltest', prorettype => 'time',
proargtypes => 'interval time', prosrc => 'select $2 + $1' },
{ oid => '1850',
@@ -5265,7 +5265,7 @@
proparallel => 'r', prorettype => 'record', proargtypes => '',
proallargtypes => '{int4,text,pg_lsn,int4,pg_lsn,pg_lsn,int4,timestamptz,timestamptz,pg_lsn,timestamptz,text,text,int4,text}',
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
- proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
+ proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_location,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
prosrc => 'pg_stat_get_wal_receiver' },
{ oid => '8595', descr => 'statistics: information about replication slots',
proname => 'pg_stat_get_replication_slots', prorows => '10',
@@ -5276,12 +5276,12 @@
proargnames => '{slot_name,spill_txns,spill_count,spill_bytes,stream_txns,stream_count,stream_bytes,stats_reset}',
prosrc => 'pg_stat_get_replication_slots' },
{ oid => '6118', descr => 'statistics: information about subscription',
- proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
+ proname => 'pg_stat_get_sub', proisstrict => 'f', provolatile => 's',
proparallel => 'r', prorettype => 'record', proargtypes => 'oid',
proallargtypes => '{oid,oid,oid,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}',
proargmodes => '{i,o,o,o,o,o,o,o,o}',
- proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}',
- prosrc => 'pg_stat_get_subscription' },
+ proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_location,latest_end_time}',
+ prosrc => 'pg_stat_get_sub' },
{ oid => '2026', descr => 'statistics: current backend PID',
proname => 'pg_backend_pid', provolatile => 's', proparallel => 'r',
prorettype => 'int4', proargtypes => '', prosrc => 'pg_backend_pid' },
@@ -5735,11 +5735,11 @@
proargtypes => 'timetz int4', prosrc => 'timetz_scale' },
{ oid => '2003',
- proname => 'textanycat', prolang => 'sql', provolatile => 's',
+ proname => 'textanycat', prolang => 'sqltest', provolatile => 's',
prorettype => 'text', proargtypes => 'text anynonarray',
prosrc => 'select $1 || $2::pg_catalog.text' },
{ oid => '2004',
- proname => 'anytextcat', prolang => 'sql', provolatile => 's',
+ proname => 'anytextcat', prolang => 'sqltest', provolatile => 's',
prorettype => 'text', proargtypes => 'anynonarray text',
prosrc => 'select $1::pg_catalog.text || $2' },
@@ -5839,15 +5839,15 @@
proargtypes => 'timestamp timestamp timestamp timestamp',
prosrc => 'overlaps_timestamp' },
{ oid => '2042', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '2043', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp timestamp timestamp interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '2044', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp timestamp',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
{ oid => '2045', descr => 'less-equal-greater',
@@ -5913,7 +5913,7 @@
proargtypes => 'timestamp timestamp', prosrc => 'timestamp_age' },
{ oid => '2059',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'sqltest', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamp',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp without time zone), $1)' },
@@ -5934,7 +5934,7 @@
proname => 'substring', prorettype => 'text', proargtypes => 'text text',
prosrc => 'textregexsubstr' },
{ oid => '2074', descr => 'extract text matching SQL regular expression',
- proname => 'substring', prolang => 'sql', prorettype => 'text',
+ proname => 'substring', prolang => 'sqltest', prorettype => 'text',
proargtypes => 'text text text',
prosrc => 'select pg_catalog.substring($1, pg_catalog.similar_to_escape($2, $3))' },
@@ -6282,11 +6282,11 @@
proname => 'pg_sleep', provolatile => 'v', prorettype => 'void',
proargtypes => 'float8', prosrc => 'pg_sleep' },
{ oid => '3935', descr => 'sleep for the specified interval',
- proname => 'pg_sleep_for', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_for', prolang => 'sqltest', provolatile => 'v',
prorettype => 'void', proargtypes => 'interval',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from pg_catalog.clock_timestamp() operator(pg_catalog.+) $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '3936', descr => 'sleep until the specified time',
- proname => 'pg_sleep_until', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_until', prolang => 'sqltest', provolatile => 'v',
prorettype => 'void', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '315', descr => 'Is JIT compilation available in this session?',
@@ -7097,7 +7097,7 @@
proargtypes => 'name', prosrc => 'pg_database_size_name' },
{ oid => '2325',
descr => 'disk space usage for the main fork of the specified table or index',
- proname => 'pg_relation_size', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_relation_size', prolang => 'sqltest', provolatile => 'v',
prorettype => 'int8', proargtypes => 'regclass',
prosrc => 'select pg_catalog.pg_relation_size($1, \'main\')' },
{ oid => '2332',
@@ -7999,21 +7999,21 @@
# formerly-missing interval + datetime operators
{ oid => '2546',
- proname => 'interval_pl_date', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'interval_pl_date', prolang => 'sqltest', prorettype => 'timestamp',
proargtypes => 'interval date', prosrc => 'select $2 + $1' },
{ oid => '2547',
- proname => 'interval_pl_timetz', prolang => 'sql', prorettype => 'timetz',
+ proname => 'interval_pl_timetz', prolang => 'sqltest', prorettype => 'timetz',
proargtypes => 'interval timetz', prosrc => 'select $2 + $1' },
{ oid => '2548',
- proname => 'interval_pl_timestamp', prolang => 'sql',
+ proname => 'interval_pl_timestamp', prolang => 'sqltest',
prorettype => 'timestamp', proargtypes => 'interval timestamp',
prosrc => 'select $2 + $1' },
{ oid => '2549',
- proname => 'interval_pl_timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'interval_pl_timestamptz', prolang => 'sqltest', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'interval timestamptz',
prosrc => 'select $2 + $1' },
{ oid => '2550',
- proname => 'integer_pl_date', prolang => 'sql', prorettype => 'date',
+ proname => 'integer_pl_date', prolang => 'sqltest', prorettype => 'date',
proargtypes => 'int4 date', prosrc => 'select $2 + $1' },
{ oid => '2556', descr => 'get OIDs of databases in a tablespace',
@@ -8405,7 +8405,7 @@
proname => 'xpath', prorettype => '_xml', proargtypes => 'text xml _text',
prosrc => 'xpath' },
{ oid => '2932', descr => 'evaluate XPath expression',
- proname => 'xpath', prolang => 'sql', prorettype => '_xml',
+ proname => 'xpath', prolang => 'sqltest', prorettype => '_xml',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath($1, $2, \'{}\'::pg_catalog.text[])' },
@@ -8418,7 +8418,7 @@
proname => 'xpath_exists', prorettype => 'bool',
proargtypes => 'text xml _text', prosrc => 'xpath_exists' },
{ oid => '3050', descr => 'test XML value against XPath expression',
- proname => 'xpath_exists', prolang => 'sql', prorettype => 'bool',
+ proname => 'xpath_exists', prolang => 'sqltest', prorettype => 'bool',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '3051', descr => 'determine if a string is well formed XML',
@@ -8684,7 +8684,7 @@
proname => 'pg_lsn_pli', prorettype => 'pg_lsn',
proargtypes => 'pg_lsn numeric', prosrc => 'pg_lsn_pli' },
{ oid => '5023',
- proname => 'numeric_pl_pg_lsn', prolang => 'sql', prorettype => 'pg_lsn',
+ proname => 'numeric_pl_pg_lsn', prolang => 'sqltest', prorettype => 'pg_lsn',
proargtypes => 'numeric pg_lsn', prosrc => 'select $2 + $1' },
{ oid => '5024',
proname => 'pg_lsn_mii', prorettype => 'pg_lsn',
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_sub.h
similarity index 77%
rename from src/include/catalog/pg_subscription.h
rename to src/include/catalog/pg_sub.h
index e3618028f7..d8dcc056de 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_sub.h
@@ -1,12 +1,12 @@
/* -------------------------------------------------------------------------
*
- * pg_subscription.h
- * definition of the "subscription" system catalog (pg_subscription)
+ * pg_sub.h
+ * definition of the "subscription" system catalog (pg_sub)
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * src/include/catalog/pg_subscription.h
+ * src/include/catalog/pg_sub.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
@@ -18,13 +18,13 @@
#define PG_SUBSCRIPTION_H
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_d.h"
+#include "catalog/pg_sub_d.h"
#include "nodes/pg_list.h"
/* ----------------
- * pg_subscription definition. cpp turns this into
- * typedef struct FormData_pg_subscription
+ * pg_sub definition. cpp turns this into
+ * typedef struct FormData_pg_sub
* ----------------
*/
@@ -36,7 +36,7 @@
*
* NOTE: When adding a column, also update system_views.sql.
*/
-CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
+CATALOG(pg_sub,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
@@ -45,7 +45,7 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
Oid subowner; /* Owner of the subscription */
- bool subenabled; /* True if the subscription is enabled (the
+ bool subactive; /* True if the subscription is enabled (the
* worker should be running) */
bool subbinary; /* True if the subscription wants the
@@ -66,17 +66,17 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
/* List of publications subscribed to */
text subpublications[1] BKI_FORCE_NOT_NULL;
#endif
-} FormData_pg_subscription;
+} FormData_pg_sub;
-typedef FormData_pg_subscription *Form_pg_subscription;
+typedef FormData_pg_sub *Form_pg_sub;
-DECLARE_TOAST(pg_subscription, 4183, 4184);
+DECLARE_TOAST(pg_sub, 4183, 4184);
#define PgSubscriptionToastTable 4183
#define PgSubscriptionToastIndex 4184
-DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_sub_oid_index, 6114, on pg_sub using btree(oid oid_ops));
#define SubscriptionObjectIndexId 6114
-DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
+DECLARE_UNIQUE_INDEX(pg_sub_subname_index, 6115, on pg_sub using btree(subdbid oid_ops, subname name_ops));
#define SubscriptionNameIndexId 6115
typedef struct Subscription
diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_sub_rel.h
similarity index 81%
rename from src/include/catalog/pg_subscription_rel.h
rename to src/include/catalog/pg_sub_rel.h
index 06663b9f16..e76a256889 100644
--- a/src/include/catalog/pg_subscription_rel.h
+++ b/src/include/catalog/pg_sub_rel.h
@@ -1,13 +1,13 @@
/* -------------------------------------------------------------------------
*
- * pg_subscription_rel.h
+ * pg_sub_rel.h
* definition of the system catalog containing the state for each
- * replicated table in each subscription (pg_subscription_rel)
+ * replicated table in each subscription (pg_sub_rel)
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * src/include/catalog/pg_subscription_rel.h
+ * src/include/catalog/pg_sub_rel.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
@@ -20,15 +20,15 @@
#include "access/xlogdefs.h"
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_rel_d.h"
+#include "catalog/pg_sub_rel_d.h"
#include "nodes/pg_list.h"
/* ----------------
- * pg_subscription_rel definition. cpp turns this into
- * typedef struct FormData_pg_subscription_rel
+ * pg_sub_rel definition. cpp turns this into
+ * typedef struct FormData_pg_sub_rel
* ----------------
*/
-CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
+CATALOG(pg_sub_rel,6102,SubscriptionRelRelationId)
{
Oid srsubid; /* Oid of subscription */
Oid srrelid; /* Oid of relation */
@@ -45,11 +45,11 @@ CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
* coordination, or NULL if not
* valid */
#endif
-} FormData_pg_subscription_rel;
+} FormData_pg_sub_rel;
-typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;
+typedef FormData_pg_sub_rel *Form_pg_sub_rel;
-DECLARE_UNIQUE_INDEX(pg_subscription_rel_srrelid_srsubid_index, 6117, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_sub_rel_srrelid_srsubid_index, 6117, on pg_sub_rel using btree(srrelid oid_ops, srsubid oid_ops));
#define SubscriptionRelSrrelidSrsubidIndexId 6117
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h
index d046022e49..c7aeffb0b2 100644
--- a/src/include/replication/worker_internal.h
+++ b/src/include/replication/worker_internal.h
@@ -15,7 +15,7 @@
#include <signal.h>
#include "access/xlogdefs.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
#include "storage/spin.h"
diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h
index 541a438387..ae07279501 100644
--- a/src/include/utils/acl.h
+++ b/src/include/utils/acl.h
@@ -303,7 +303,7 @@ extern bool pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid);
extern bool pg_event_trigger_ownercheck(Oid et_oid, Oid roleid);
extern bool pg_extension_ownercheck(Oid ext_oid, Oid roleid);
extern bool pg_publication_ownercheck(Oid pub_oid, Oid roleid);
-extern bool pg_subscription_ownercheck(Oid sub_oid, Oid roleid);
+extern bool pg_sub_ownercheck(Oid sub_oid, Oid roleid);
extern bool pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid);
extern bool has_createrole_privilege(Oid roleid);
extern bool has_bypassrls_privilege(Oid roleid);
diff --git a/src/pl/plperl/expected/plperl_trigger.out b/src/pl/plperl/expected/plperl_trigger.out
index d4879e2f03..c370a232d3 100644
--- a/src/pl/plperl/expected/plperl_trigger.out
+++ b/src/pl/plperl/expected/plperl_trigger.out
@@ -355,7 +355,7 @@ create event trigger perl_a_snitch on ddl_command_start
execute procedure perlsnitch();
create event trigger perl_b_snitch on ddl_command_end
execute procedure perlsnitch();
-create or replace function foobar() returns int language sql as $$select 1;$$;
+create or replace function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
NOTICE: perlsnitch: ddl_command_start CREATE FUNCTION
NOTICE: perlsnitch: ddl_command_end CREATE FUNCTION
alter function foobar() cost 77;
diff --git a/src/pl/plperl/sql/plperl_trigger.sql b/src/pl/plperl/sql/plperl_trigger.sql
index 4adddeb80a..c893fe772a 100644
--- a/src/pl/plperl/sql/plperl_trigger.sql
+++ b/src/pl/plperl/sql/plperl_trigger.sql
@@ -232,7 +232,7 @@ create event trigger perl_a_snitch on ddl_command_start
create event trigger perl_b_snitch on ddl_command_end
execute procedure perlsnitch();
-create or replace function foobar() returns int language sql as $$select 1;$$;
+create or replace function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
alter function foobar() cost 77;
drop function foobar();
diff --git a/src/pl/plpgsql/src/expected/plpgsql_simple.out b/src/pl/plpgsql/src/expected/plpgsql_simple.out
index 5a2fefa03e..8fa8893b01 100644
--- a/src/pl/plpgsql/src/expected/plpgsql_simple.out
+++ b/src/pl/plpgsql/src/expected/plpgsql_simple.out
@@ -2,7 +2,7 @@
-- Tests for plpgsql's handling of "simple" expressions
--
-- Check that changes to an inline-able function are handled correctly
-create function simplesql(int) returns int language sql
+create function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1';
create function simplecaller() returns int language plpgsql
as $$
@@ -12,7 +12,7 @@ begin
for n in 1..10 loop
sum := sum + simplesql(n);
if n = 5 then
- create or replace function simplesql(int) returns int language sql
+ create or replace function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1 + 100';
end if;
end loop;
diff --git a/src/pl/plpgsql/src/expected/plpgsql_transaction.out b/src/pl/plpgsql/src/expected/plpgsql_transaction.out
index 5f576231c3..6bba3839f1 100644
--- a/src/pl/plpgsql/src/expected/plpgsql_transaction.out
+++ b/src/pl/plpgsql/src/expected/plpgsql_transaction.out
@@ -491,7 +491,7 @@ CONTEXT: PL/pgSQL function inline_code_block line 3 at EXECUTE
-- snapshot handling test
TRUNCATE test2;
CREATE PROCEDURE transaction_test9()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO test2 VALUES (42);
$$;
diff --git a/src/pl/plpgsql/src/sql/plpgsql_simple.sql b/src/pl/plpgsql/src/sql/plpgsql_simple.sql
index 8a95768073..9dc14b425b 100644
--- a/src/pl/plpgsql/src/sql/plpgsql_simple.sql
+++ b/src/pl/plpgsql/src/sql/plpgsql_simple.sql
@@ -3,7 +3,7 @@
--
-- Check that changes to an inline-able function are handled correctly
-create function simplesql(int) returns int language sql
+create function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1';
create function simplecaller() returns int language plpgsql
@@ -14,7 +14,7 @@ begin
for n in 1..10 loop
sum := sum + simplesql(n);
if n = 5 then
- create or replace function simplesql(int) returns int language sql
+ create or replace function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1 + 100';
end if;
end loop;
diff --git a/src/pl/plpgsql/src/sql/plpgsql_transaction.sql b/src/pl/plpgsql/src/sql/plpgsql_transaction.sql
index 7575655c1a..07a9c7b9d7 100644
--- a/src/pl/plpgsql/src/sql/plpgsql_transaction.sql
+++ b/src/pl/plpgsql/src/sql/plpgsql_transaction.sql
@@ -410,7 +410,7 @@ $$;
TRUNCATE test2;
CREATE PROCEDURE transaction_test9()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO test2 VALUES (42);
$$;
diff --git a/src/pl/tcl/expected/pltcl_setup.out b/src/pl/tcl/expected/pltcl_setup.out
index ed809f02bf..6452cde8b4 100644
--- a/src/pl/tcl/expected/pltcl_setup.out
+++ b/src/pl/tcl/expected/pltcl_setup.out
@@ -139,7 +139,7 @@ create function tclsnitch() returns event_trigger language pltcl as $$
$$;
create event trigger tcl_a_snitch on ddl_command_start execute procedure tclsnitch();
create event trigger tcl_b_snitch on ddl_command_end execute procedure tclsnitch();
-create function foobar() returns int language sql as $$select 1;$$;
+create function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
NOTICE: tclsnitch: ddl_command_start CREATE FUNCTION
NOTICE: tclsnitch: ddl_command_end CREATE FUNCTION
alter function foobar() cost 77;
diff --git a/src/pl/tcl/sql/pltcl_setup.sql b/src/pl/tcl/sql/pltcl_setup.sql
index e9f59989b5..8296e4f6f7 100644
--- a/src/pl/tcl/sql/pltcl_setup.sql
+++ b/src/pl/tcl/sql/pltcl_setup.sql
@@ -156,7 +156,7 @@ $$;
create event trigger tcl_a_snitch on ddl_command_start execute procedure tclsnitch();
create event trigger tcl_b_snitch on ddl_command_end execute procedure tclsnitch();
-create function foobar() returns int language sql as $$select 1;$$;
+create function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
alter function foobar() cost 77;
drop function foobar();
diff --git a/src/test/isolation/specs/deadlock-parallel.spec b/src/test/isolation/specs/deadlock-parallel.spec
index 7ad290c0bd..5ae4082052 100644
--- a/src/test/isolation/specs/deadlock-parallel.spec
+++ b/src/test/isolation/specs/deadlock-parallel.spec
@@ -36,10 +36,10 @@
setup
{
- create function lock_share(int,int) returns int language sql as
+ create function lock_share(int,int) returns int LANGUAGE SQLTEST as
'select pg_advisory_xact_lock_shared($1); select 1;' parallel safe;
- create function lock_excl(int,int) returns int language sql as
+ create function lock_excl(int,int) returns int LANGUAGE SQLTEST as
'select pg_advisory_xact_lock($1); select 1;' parallel safe;
create table bigt as select x from generate_series(1, 10000) x;
diff --git a/src/test/isolation/specs/eval-plan-qual.spec b/src/test/isolation/specs/eval-plan-qual.spec
index 70fa320fc4..c5558284d3 100644
--- a/src/test/isolation/specs/eval-plan-qual.spec
+++ b/src/test/isolation/specs/eval-plan-qual.spec
@@ -9,7 +9,7 @@ setup
CREATE TABLE accounts (accountid text PRIMARY KEY, balance numeric not null);
INSERT INTO accounts VALUES ('checking', 600), ('savings', 600);
- CREATE FUNCTION update_checking(int) RETURNS bool LANGUAGE sql AS $$
+ CREATE FUNCTION update_checking(int) RETURNS bool LANGUAGE sqltest AS $$
UPDATE accounts SET balance = balance + 1 WHERE accountid = 'checking'; SELECT true;$$;
CREATE TABLE accounts_ext (accountid text PRIMARY KEY, balance numeric not null, other text);
diff --git a/src/test/isolation/specs/insert-conflict-specconflict.spec b/src/test/isolation/specs/insert-conflict-specconflict.spec
index 6028397491..4c7dae67e2 100644
--- a/src/test/isolation/specs/insert-conflict-specconflict.spec
+++ b/src/test/isolation/specs/insert-conflict-specconflict.spec
@@ -31,7 +31,7 @@ setup
RETURN $1;
END;$$;
- CREATE OR REPLACE FUNCTION ctoast_large_val() RETURNS TEXT LANGUAGE SQL AS 'select array_agg(md5(g::text))::text from generate_series(1, 256) g';
+ CREATE OR REPLACE FUNCTION ctoast_large_val() RETURNS TEXT LANGUAGE SQLTEST AS 'select array_agg(md5(g::text))::text from generate_series(1, 256) g';
CREATE TABLE upserttest(key text, data text);
diff --git a/src/test/isolation/specs/read-write-unique-3.spec b/src/test/isolation/specs/read-write-unique-3.spec
index 52d287721b..ff8f436df6 100644
--- a/src/test/isolation/specs/read-write-unique-3.spec
+++ b/src/test/isolation/specs/read-write-unique-3.spec
@@ -9,7 +9,7 @@ setup
);
CREATE OR REPLACE FUNCTION insert_unique(k integer, v text) RETURNS void
- LANGUAGE SQL AS $$
+ LANGUAGE SQLTEST AS $$
INSERT INTO test (key, val) SELECT k, v WHERE NOT EXISTS (SELECT key FROM test WHERE key = k);
$$;
}
diff --git a/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out b/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
index b2d898a7d1..816710e58f 100644
--- a/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
+++ b/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
@@ -12,7 +12,7 @@ CREATE USER regress_dummy_seclabel_user2;
CREATE TABLE dummy_seclabel_tbl1 (a int, b text);
CREATE TABLE dummy_seclabel_tbl2 (x int, y text);
CREATE VIEW dummy_seclabel_view1 AS SELECT * FROM dummy_seclabel_tbl2;
-CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ language sql;
+CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ LANGUAGE SQLTEST;
CREATE DOMAIN dummy_seclabel_domain AS text;
ALTER TABLE dummy_seclabel_tbl1 OWNER TO regress_dummy_seclabel_user1;
ALTER TABLE dummy_seclabel_tbl2 OWNER TO regress_dummy_seclabel_user2;
diff --git a/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql b/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
index 8c347b6a68..a7d607b2be 100644
--- a/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
+++ b/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
@@ -17,7 +17,7 @@ CREATE USER regress_dummy_seclabel_user2;
CREATE TABLE dummy_seclabel_tbl1 (a int, b text);
CREATE TABLE dummy_seclabel_tbl2 (x int, y text);
CREATE VIEW dummy_seclabel_view1 AS SELECT * FROM dummy_seclabel_tbl2;
-CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ language sql;
+CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ LANGUAGE SQLTEST;
CREATE DOMAIN dummy_seclabel_domain AS text;
ALTER TABLE dummy_seclabel_tbl1 OWNER TO regress_dummy_seclabel_user1;
diff --git a/src/test/modules/test_ddl_deparse/expected/create_transform.out b/src/test/modules/test_ddl_deparse/expected/create_transform.out
index 5066051fca..a9831f2564 100644
--- a/src/test/modules/test_ddl_deparse/expected/create_transform.out
+++ b/src/test/modules/test_ddl_deparse/expected/create_transform.out
@@ -8,8 +8,8 @@
-- We choose some random built-in functions that have the right signature.
-- This won't actually be used, because the SQL function language
-- doesn't implement transforms (there would be no point).
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
NOTICE: DDL test: type simple, tag CREATE TRANSFORM
-DROP TRANSFORM FOR int LANGUAGE SQL;
+DROP TRANSFORM FOR int LANGUAGE SQLTEST;
diff --git a/src/test/modules/test_ddl_deparse/expected/opfamily.out b/src/test/modules/test_ddl_deparse/expected/opfamily.out
index 14bd6037cd..d9a882112c 100644
--- a/src/test/modules/test_ddl_deparse/expected/opfamily.out
+++ b/src/test/modules/test_ddl_deparse/expected/opfamily.out
@@ -56,7 +56,7 @@ NOTICE: DDL test: type alter operator family, tag ALTER OPERATOR FAMILY
-- copied from alter_table.sql
create type ctype as (f1 int, f2 text);
NOTICE: DDL test: type simple, tag CREATE TYPE
-create function same(ctype, ctype) returns boolean language sql
+create function same(ctype, ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
NOTICE: DDL test: type simple, tag CREATE FUNCTION
create operator =(procedure = same, leftarg = ctype, rightarg = ctype);
diff --git a/src/test/modules/test_ddl_deparse/sql/create_transform.sql b/src/test/modules/test_ddl_deparse/sql/create_transform.sql
index 970d89e03d..715ee2a06c 100644
--- a/src/test/modules/test_ddl_deparse/sql/create_transform.sql
+++ b/src/test/modules/test_ddl_deparse/sql/create_transform.sql
@@ -9,8 +9,8 @@
-- We choose some random built-in functions that have the right signature.
-- This won't actually be used, because the SQL function language
-- doesn't implement transforms (there would be no point).
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
-DROP TRANSFORM FOR int LANGUAGE SQL;
+DROP TRANSFORM FOR int LANGUAGE SQLTEST;
diff --git a/src/test/modules/test_ddl_deparse/sql/opfamily.sql b/src/test/modules/test_ddl_deparse/sql/opfamily.sql
index b2bacbbcbd..f16bc90bec 100644
--- a/src/test/modules/test_ddl_deparse/sql/opfamily.sql
+++ b/src/test/modules/test_ddl_deparse/sql/opfamily.sql
@@ -42,7 +42,7 @@ alter operator family integer_ops using btree add
-- copied from alter_table.sql
create type ctype as (f1 int, f2 text);
-create function same(ctype, ctype) returns boolean language sql
+create function same(ctype, ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
create operator =(procedure = same, leftarg = ctype, rightarg = ctype);
diff --git a/src/test/modules/test_extensions/test_ext8--1.0.sql b/src/test/modules/test_extensions/test_ext8--1.0.sql
index 1561ffefaa..f75112870a 100644
--- a/src/test/modules/test_extensions/test_ext8--1.0.sql
+++ b/src/test/modules/test_extensions/test_ext8--1.0.sql
@@ -13,9 +13,9 @@ create table ext8_table1 (f1 posint);
create temp table ext8_temp_table1 (f1 posint);
create function ext8_even (posint) returns bool as
- 'select ($1 % 2) = 0' language sql;
+ 'select ($1 % 2) = 0' LANGUAGE SQLTEST;
create function pg_temp.ext8_temp_even (posint) returns bool as
- 'select ($1 % 2) = 0' language sql;
+ 'select ($1 % 2) = 0' LANGUAGE SQLTEST;
-- we intentionally don't drop the temp objects before exiting
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl
index 501aff0920..b05b1f25a2 100644
--- a/src/test/modules/test_pg_dump/t/001_base.pl
+++ b/src/test/modules/test_pg_dump/t/001_base.pl
@@ -564,7 +564,7 @@ my %tests = (
'CREATE FUNCTION regress_pg_dump_schema.test_func' => {
regexp => qr/^
\QCREATE FUNCTION regress_pg_dump_schema.test_func() RETURNS integer\E
- \n\s+\QLANGUAGE sql\E
+ \n\s+\QLANGUAGE sqltest\E
\n/xm,
like => { binary_upgrade => 1, },
},
diff --git a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql
index 110f7eef66..9c9f381ca5 100644
--- a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql
+++ b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql
@@ -28,7 +28,7 @@ GRANT SELECT(col1) ON regress_pg_dump_table TO public;
GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role;
REVOKE SELECT(col2) ON regress_pg_dump_table FROM regress_dump_test_role;
-CREATE FUNCTION wgo_then_no_access() RETURNS int LANGUAGE SQL AS 'SELECT 1';
+CREATE FUNCTION wgo_then_no_access() RETURNS int LANGUAGE SQLTEST AS 'SELECT 1';
GRANT ALL ON FUNCTION wgo_then_no_access()
TO pg_signal_backend WITH GRANT OPTION;
@@ -54,7 +54,7 @@ CREATE TYPE regress_pg_dump_schema.test_type AS (col1 int);
GRANT USAGE ON TYPE regress_pg_dump_schema.test_type TO regress_dump_test_role;
CREATE FUNCTION regress_pg_dump_schema.test_func () RETURNS int
-AS 'SELECT 1;' LANGUAGE SQL;
+AS 'SELECT 1;' LANGUAGE SQLTEST;
GRANT EXECUTE ON FUNCTION regress_pg_dump_schema.test_func() TO regress_dump_test_role;
CREATE AGGREGATE regress_pg_dump_schema.test_agg(int2)
diff --git a/src/test/modules/unsafe_tests/expected/rolenames.out b/src/test/modules/unsafe_tests/expected/rolenames.out
index eb608fdc2e..14b0590c74 100644
--- a/src/test/modules/unsafe_tests/expected/rolenames.out
+++ b/src/test/modules/unsafe_tests/expected/rolenames.out
@@ -14,7 +14,7 @@ SELECT r.rolname, v.keyword, r.rolcanlogin, r.rolreplication
AS v(uname, keyword)
ON (r.rolname = v.uname)
ORDER BY 1, 2;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chksetconfig()
RETURNS TABLE (db name, "role" name, rolkeyword text, setconfig text[])
AS $$
@@ -30,7 +30,7 @@ SELECT COALESCE(d.datname, 'ALL'), COALESCE(r.rolname, 'ALL'),
ON (r.rolname = v.uname)
WHERE (r.rolname) IN ('Public', 'current_user', 'regress_testrol1', 'regress_testrol2')
ORDER BY 1, 2, 3;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chkumapping()
RETURNS TABLE (umname name, umserver name, umoptions text[])
AS $$
@@ -39,7 +39,7 @@ SELECT r.rolname, s.srvname, m.umoptions
LEFT JOIN pg_roles r ON (r.oid = m.umuser)
JOIN pg_foreign_server s ON (s.oid = m.umserver)
ORDER BY 2, 1;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
--
-- We test creation and use of these role names to ensure that the server
-- correctly distinguishes role keywords from quoted names that look like
diff --git a/src/test/modules/unsafe_tests/sql/rolenames.sql b/src/test/modules/unsafe_tests/sql/rolenames.sql
index adac36536d..a02fc6ae20 100644
--- a/src/test/modules/unsafe_tests/sql/rolenames.sql
+++ b/src/test/modules/unsafe_tests/sql/rolenames.sql
@@ -14,7 +14,7 @@ SELECT r.rolname, v.keyword, r.rolcanlogin, r.rolreplication
AS v(uname, keyword)
ON (r.rolname = v.uname)
ORDER BY 1, 2;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chksetconfig()
RETURNS TABLE (db name, "role" name, rolkeyword text, setconfig text[])
@@ -31,7 +31,7 @@ SELECT COALESCE(d.datname, 'ALL'), COALESCE(r.rolname, 'ALL'),
ON (r.rolname = v.uname)
WHERE (r.rolname) IN ('Public', 'current_user', 'regress_testrol1', 'regress_testrol2')
ORDER BY 1, 2, 3;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chkumapping()
RETURNS TABLE (umname name, umserver name, umoptions text[])
@@ -41,7 +41,7 @@ SELECT r.rolname, s.srvname, m.umoptions
LEFT JOIN pg_roles r ON (r.oid = m.umuser)
JOIN pg_foreign_server s ON (s.oid = m.umserver)
ORDER BY 2, 1;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
--
-- We test creation and use of these role names to ensure that the server
diff --git a/src/test/regress/expected/alter_generic.out b/src/test/regress/expected/alter_generic.out
index 505eb7ede5..fe47e5c11a 100644
--- a/src/test/regress/expected/alter_generic.out
+++ b/src/test/regress/expected/alter_generic.out
@@ -18,9 +18,9 @@ SET search_path = alt_nsp1, public;
-- Function and Aggregate
--
SET SESSION AUTHORIZATION regress_alter_generic_user1;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 1';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 1';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0
@@ -50,9 +50,9 @@ ERROR: must be member of role "regress_alter_generic_user2"
ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3; -- OK
ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2; -- OK
SET SESSION AUTHORIZATION regress_alter_generic_user2;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 2';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 2';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100
@@ -410,7 +410,7 @@ DROP OPERATOR FAMILY alt_opf11 USING gist;
-- Should fail. btree comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf12 USING btree;
-CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2);
ERROR: btree comparison functions must return integer
DROP OPERATOR FAMILY alt_opf12 USING btree;
@@ -419,7 +419,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf13 USING hash;
-CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4);
ERROR: hash function 1 must return integer
DROP OPERATOR FAMILY alt_opf13 USING hash;
@@ -428,7 +428,7 @@ ROLLBACK;
-- Should fail. btree comparison functions should have two arguments in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf14 USING btree;
-CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4);
ERROR: btree comparison functions must have two arguments
DROP OPERATOR FAMILY alt_opf14 USING btree;
@@ -437,7 +437,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should have one argument in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf15 USING hash;
-CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2);
ERROR: hash function 1 must have one argument
DROP OPERATOR FAMILY alt_opf15 USING hash;
diff --git a/src/test/regress/expected/alter_operator.out b/src/test/regress/expected/alter_operator.out
index 71bd484282..f66351528c 100644
--- a/src/test/regress/expected/alter_operator.out
+++ b/src/test/regress/expected/alter_operator.out
@@ -1,5 +1,5 @@
CREATE FUNCTION alter_op_test_fn(boolean, boolean)
-RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
+RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sqltest IMMUTABLE;
CREATE FUNCTION customcontsel(internal, oid, internal, integer)
RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT;
CREATE OPERATOR === (
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 0ce6ee4622..df6fa3b29b 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2804,7 +2804,7 @@ drop type lockmodes;
--
create function test_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql returns null on null input;
+ LANGUAGE SQLTEST returns null on null input;
select test_strict(NULL);
test_strict
-------------
@@ -2820,7 +2820,7 @@ select test_strict(NULL);
create function non_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql called on null input;
+ LANGUAGE SQLTEST called on null input;
select non_strict(NULL);
non_strict
-------------------
@@ -2841,10 +2841,10 @@ create schema alter1;
create schema alter2;
create table alter1.t1(f1 serial primary key, f2 int check (f2 > 0));
create view alter1.v1 as select * from alter1.t1;
-create function alter1.plus1(int) returns int as 'select $1+1' language sql;
+create function alter1.plus1(int) returns int as 'select $1+1' LANGUAGE SQLTEST;
create domain alter1.posint integer check (value > 0);
create type alter1.ctype as (f1 int, f2 text);
-create function alter1.same(alter1.ctype, alter1.ctype) returns boolean language sql
+create function alter1.same(alter1.ctype, alter1.ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
create operator alter1.=(procedure = alter1.same, leftarg = alter1.ctype, rightarg = alter1.ctype);
create operator class alter1.ctype_hash_ops default for type alter1.ctype using hash as
@@ -4338,7 +4338,7 @@ drop function func_part_attach();
-- test case where the partitioning operator is a SQL function whose
-- evaluation results in the table's relcache being rebuilt partway through
-- the execution of an ATTACH PARTITION command
-create function at_test_sql_partop (int4, int4) returns int language sql
+create function at_test_sql_partop (int4, int4) returns int LANGUAGE SQLTEST
as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$;
create operator class at_test_sql_partop for type int4 using btree as
operator 1 < (int4, int4), operator 2 <= (int4, int4),
diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out
index 8bc7721e7d..110eb283d1 100644
--- a/src/test/regress/expected/arrays.out
+++ b/src/test/regress/expected/arrays.out
@@ -1580,12 +1580,12 @@ drop type comptype;
create or replace function unnest1(anyarray)
returns setof anyelement as $$
select $1[s] from generate_subscripts($1,1) g(s);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create or replace function unnest2(anyarray)
returns setof anyelement as $$
select $1[s1][s2] from generate_subscripts($1,1) g1(s1),
generate_subscripts($1,2) g2(s2);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select * from unnest1(array[1,2,3]);
unnest1
---------
diff --git a/src/test/regress/expected/case.out b/src/test/regress/expected/case.out
index 7fcfe9a7a6..b46fd1d378 100644
--- a/src/test/regress/expected/case.out
+++ b/src/test/regress/expected/case.out
@@ -337,7 +337,7 @@ CREATE DOMAIN foodomain AS text;
CREATE FUNCTION volfoo(text) returns foodomain as
'begin return $1::foodomain; end' language plpgsql volatile;
CREATE FUNCTION inline_eq(foodomain, foodomain) returns boolean as
- 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' language sql;
+ 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' LANGUAGE SQLTEST;
CREATE OPERATOR = (procedure = inline_eq,
leftarg = foodomain, rightarg = foodomain);
SELECT CASE volfoo('bar') WHEN 'foo'::foodomain THEN 'is foo' ELSE 'is not foo' END;
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index bc3752e923..41ea82261d 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -811,9 +811,9 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
AS $$ begin return $1 < $2; end $$;
@@ -935,7 +935,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER
(4 rows)
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
a | dup
---+-----
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index 580b00eea7..fa91f76dc1 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -848,9 +848,9 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
AS $$ begin return $1 < $2; end $$;
@@ -972,7 +972,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER
(4 rows)
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
a | dup
---+-----
diff --git a/src/test/regress/expected/collate.out b/src/test/regress/expected/collate.out
index c42ab8f703..4279c6e9d0 100644
--- a/src/test/regress/expected/collate.out
+++ b/src/test/regress/expected/collate.out
@@ -537,7 +537,7 @@ SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2;
(4 rows)
-- result of a SQL function
-CREATE FUNCTION vc (text) RETURNS text LANGUAGE sql
+CREATE FUNCTION vc (text) RETURNS text LANGUAGE sqltest
AS 'select $1::varchar';
SELECT a, b FROM collate_test1 ORDER BY a, vc(b);
a | b
@@ -568,7 +568,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER
(4 rows)
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
a | dup
---+-----
diff --git a/src/test/regress/expected/create_aggregate.out b/src/test/regress/expected/create_aggregate.out
index dcf6909423..0236cfbed1 100644
--- a/src/test/regress/expected/create_aggregate.out
+++ b/src/test/regress/expected/create_aggregate.out
@@ -38,7 +38,7 @@ COMMENT ON AGGREGATE newcnt (*) IS 'an agg(*) comment';
COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment';
-- multi-argument aggregate
create function sum3(int8,int8,int8) returns int8 as
-'select $1 + $2 + $3' language sql strict immutable;
+'select $1 + $2 + $3' LANGUAGE SQLTEST strict immutable;
create aggregate sum2(int8,int8) (
sfunc = sum3, stype = int8,
initcond = '0'
@@ -47,10 +47,10 @@ create aggregate sum2(int8,int8) (
create type aggtype as (a integer, b integer, c text);
create function aggf_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql strict immutable;
+LANGUAGE SQLTEST strict immutable;
create function aggfns_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql immutable;
+LANGUAGE SQLTEST immutable;
create aggregate aggfstr(integer,integer,text) (
sfunc = aggf_trans, stype = aggtype[],
initcond = '{}'
@@ -60,7 +60,7 @@ create aggregate aggfns(integer,integer,text) (
initcond = '{}'
);
-- check error cases that would require run-time type coercion
-create function least_accum(int8, int8) returns int8 language sql as
+create function least_accum(int8, int8) returns int8 LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
stype = int8, sfunc = least_accum
@@ -68,7 +68,7 @@ create aggregate least_agg(int4) (
ERROR: function least_accum(bigint, bigint) requires run-time type coercion
drop function least_accum(int8, int8);
create function least_accum(anycompatible, anycompatible)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
stype = int8, sfunc = least_accum
@@ -81,13 +81,13 @@ drop function least_accum(anycompatible, anycompatible) cascade;
NOTICE: drop cascades to function least_agg(bigint)
-- variadic aggregates
create function least_accum(anyelement, variadic anyarray)
-returns anyelement language sql as
+returns anyelement LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate least_agg(variadic items anyarray) (
stype = anyelement, sfunc = least_accum
);
create function cleast_accum(anycompatible, variadic anycompatiblearray)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate cleast_agg(variadic items anycompatiblearray) (
stype = anycompatible, sfunc = cleast_accum
@@ -248,7 +248,7 @@ ERROR: cannot change routine kind
DETAIL: "myavg" is an ordinary aggregate function.
-- can't change plain function to aggregate:
create function sum4(int8,int8,int8,int8) returns int8 as
-'select $1 + $2 + $3 + $4' language sql strict immutable;
+'select $1 + $2 + $3 + $4' LANGUAGE SQLTEST strict immutable;
CREATE OR REPLACE AGGREGATE sum3 (int8,int8,int8)
(
stype = int8,
@@ -269,7 +269,7 @@ ERROR: parameter "parallel" must be SAFE, RESTRICTED, or UNSAFE
-- invalid: nonstrict inverse with strict forward function
CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS
$$ SELECT $1 - $2; $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE invalidsumdouble (float8)
(
stype = float8,
@@ -282,7 +282,7 @@ ERROR: strictness of aggregate's forward and inverse transition functions must
-- invalid: non-matching result types
CREATE FUNCTION float8mi_int(float8, float8) RETURNS int AS
$$ SELECT CAST($1 - $2 AS INT); $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE wrongreturntype (float8)
(
stype = float8,
diff --git a/src/test/regress/expected/create_cast.out b/src/test/regress/expected/create_cast.out
index 88f94a63b4..cebb491053 100644
--- a/src/test/regress/expected/create_cast.out
+++ b/src/test/regress/expected/create_cast.out
@@ -20,7 +20,7 @@ CREATE TYPE casttesttype (
alignment = int4
);
-- a dummy function to test with
-CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQL AS
+CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQLTEST AS
$$ SELECT 1; $$;
SELECT casttestfunc('foo'::text); -- fails, as there's no cast
ERROR: function casttestfunc(text) does not exist
@@ -63,7 +63,7 @@ SELECT 1234::int4::casttesttype; -- Should work now
DROP CAST (int4 AS casttesttype);
-- Try cast with a function
-CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQL AS
+CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQLTEST AS
$$ SELECT ('foo'::text || $1::text)::casttesttype; $$;
CREATE CAST (int4 AS casttesttype) WITH FUNCTION int4_casttesttype(int4) AS IMPLICIT;
SELECT 1234::int4::casttesttype; -- Should work now
diff --git a/src/test/regress/expected/create_function_3.out b/src/test/regress/expected/create_function_3.out
index ce508ae1dc..6a25967db2 100644
--- a/src/test/regress/expected/create_function_3.out
+++ b/src/test/regress/expected/create_function_3.out
@@ -14,11 +14,11 @@ SET search_path TO temp_func_test, public;
--
-- ARGUMENT and RETURN TYPES
--
-CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
-CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
+CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sqltest'
AS 'SELECT $1[1]::int';
-CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT false';
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
WHERE oid in ('functest_A_1'::regproc,
@@ -52,13 +52,13 @@ SELECT functest_A_3();
--
-- IMMUTABLE | STABLE | VOLATILE
--
-CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sqltest'
STABLE AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sqltest'
VOLATILE AS 'SELECT $1 < 0';
SELECT proname, provolatile FROM pg_proc
WHERE oid in ('functest_B_1'::regproc,
@@ -91,11 +91,11 @@ SELECT proname, provolatile FROM pg_proc
--
-- SECURITY DEFINER | INVOKER
--
-CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY DEFINER AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY INVOKER AS 'SELECT $1 < 0';
SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functest_C_1'::regproc,
@@ -125,9 +125,9 @@ SELECT proname, prosecdef FROM pg_proc
--
-- LEAKPROOF
--
-CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 100';
-CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 > 100';
SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functest_E_1'::regproc,
@@ -167,20 +167,20 @@ SET search_path TO temp_func_test, public;
ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF;
ALTER FUNCTION functest_E_2(int) LEAKPROOF;
ERROR: only superuser can define a leakproof function
-CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 < 200'; -- fail
ERROR: only superuser can define a leakproof function
RESET SESSION AUTHORIZATION;
--
-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
--
-CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 50';
-CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sqltest'
CALLED ON NULL INPUT AS 'SELECT $1 = 50';
-CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sqltest'
RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50';
-CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sqltest'
STRICT AS 'SELECT $1 = 50';
SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functest_F_1'::regproc,
@@ -217,7 +217,7 @@ SELECT pg_get_functiondef('functest_A_1'::regproc);
--------------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_a_1(text, date)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
AS $function$SELECT $1 = 'abcd' AND $2 > '2001-01-01'$function$ +
(1 row)
@@ -227,7 +227,7 @@ SELECT pg_get_functiondef('functest_B_3'::regproc);
-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_b_3(integer)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
STABLE +
AS $function$SELECT $1 = 0$function$ +
@@ -238,7 +238,7 @@ SELECT pg_get_functiondef('functest_C_3'::regproc);
-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_c_3(integer)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
SECURITY DEFINER +
AS $function$SELECT $1 < 0$function$ +
@@ -249,7 +249,7 @@ SELECT pg_get_functiondef('functest_F_2'::regproc);
-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_f_2(integer)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
STRICT +
AS $function$SELECT $1 = 50$function$ +
@@ -258,15 +258,15 @@ SELECT pg_get_functiondef('functest_F_2'::regproc);
-- information_schema tests
CREATE FUNCTION functest_IS_1(a int, b int default 1, c text default 'foo')
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1 + $2';
CREATE FUNCTION functest_IS_2(out a int, b int default 1)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
CREATE FUNCTION functest_IS_3(a int default 1, out b int)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
SELECT routine_name, ordinal_position, parameter_name, parameter_default
FROM information_schema.parameters JOIN information_schema.routines USING (specific_schema, specific_name)
@@ -285,7 +285,7 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
-- overload
-CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
DROP FUNCTION functest_b_1;
DROP FUNCTION functest_b_1; -- error, not found
@@ -294,16 +294,16 @@ DROP FUNCTION functest_b_2; -- error, ambiguous
ERROR: function name "functest_b_2" is not unique
HINT: Specify the argument list to select the function unambiguously.
-- CREATE OR REPLACE tests
-CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL AS 'SELECT $1';
-CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL WINDOW AS 'SELECT $1';
+CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST AS 'SELECT $1';
+CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST WINDOW AS 'SELECT $1';
ERROR: cannot change routine kind
DETAIL: "functest1" is a function.
-CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQL AS 'SELECT $1';
+CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQLTEST AS 'SELECT $1';
ERROR: cannot change routine kind
DETAIL: "functest1" is a function.
DROP FUNCTION functest1(a int);
-- Check behavior of VOID-returning SQL functions
-CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT a + 1 $$;
SELECT voidtest1(42);
voidtest1
@@ -311,7 +311,7 @@ SELECT voidtest1(42);
(1 row)
-CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT voidtest1(a + b) $$;
SELECT voidtest2(11,22);
voidtest2
@@ -328,7 +328,7 @@ EXPLAIN (verbose, costs off) SELECT voidtest2(11,22);
(2 rows)
CREATE TEMP TABLE sometable(f1 int);
-CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a + 1) $$;
SELECT voidtest3(17);
voidtest3
@@ -336,7 +336,7 @@ SELECT voidtest3(17);
(1 row)
-CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a - 1) RETURNING f1 $$;
SELECT voidtest4(39);
voidtest4
@@ -351,7 +351,7 @@ TABLE sometable;
38
(2 rows)
-CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQLTEST AS
$$ SELECT generate_series(1, a) $$ STABLE;
SELECT * FROM voidtest5(3);
voidtest5
diff --git a/src/test/regress/expected/create_operator.out b/src/test/regress/expected/create_operator.out
index 5303277591..93aa09a3e2 100644
--- a/src/test/regress/expected/create_operator.out
+++ b/src/test/regress/expected/create_operator.out
@@ -167,7 +167,7 @@ BEGIN TRANSACTION;
CREATE OR REPLACE FUNCTION fn_op2(boolean, boolean)
RETURNS boolean AS $$
SELECT NULL::BOOLEAN;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
CREATE OPERATOR === (
LEFTARG = boolean,
RIGHTARG = boolean,
@@ -203,7 +203,7 @@ CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op3(type_op3, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op3 FROM regress_rol_op3;
REVOKE USAGE ON TYPE type_op3 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op3;
@@ -221,7 +221,7 @@ CREATE TYPE type_op4 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op4(int8, type_op4)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op4 FROM regress_rol_op4;
REVOKE USAGE ON TYPE type_op4 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op4;
@@ -239,7 +239,7 @@ CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op5(int8, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM PUBLIC;-- Need to do this so that regress_rol_op3 is not allowed EXECUTE via PUBLIC
SET ROLE regress_rol_op5;
@@ -257,7 +257,7 @@ CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op6(int8, int8)
RETURNS type_op6 AS $$
SELECT NULL::type_op6;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op6 FROM regress_rol_op6;
REVOKE USAGE ON TYPE type_op6 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op6;
diff --git a/src/test/regress/expected/create_procedure.out b/src/test/regress/expected/create_procedure.out
index 3838fa2324..82af83c4d2 100644
--- a/src/test/regress/expected/create_procedure.out
+++ b/src/test/regress/expected/create_procedure.out
@@ -8,10 +8,10 @@ ERROR: random() is not a procedure
LINE 1: CALL random();
^
HINT: To call a function, use SELECT.
-CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQL AS $$ SELECT a $$;
+CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQLTEST AS $$ SELECT a $$;
CREATE TABLE cp_test (a int, b text);
CREATE PROCEDURE ptest1(x text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, x);
$$;
@@ -26,7 +26,7 @@ SELECT pg_get_functiondef('ptest1'::regproc);
pg_get_functiondef
---------------------------------------------------
CREATE OR REPLACE PROCEDURE public.ptest1(x text)+
- LANGUAGE sql +
+ LANGUAGE sqltest +
AS $procedure$ +
INSERT INTO cp_test VALUES (1, x); +
$procedure$ +
@@ -66,7 +66,7 @@ SELECT * FROM cp_test ORDER BY b COLLATE "C";
(3 rows)
CREATE PROCEDURE ptest2()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 5;
$$;
@@ -74,7 +74,7 @@ CALL ptest2();
-- nested CALL
TRUNCATE cp_test;
CREATE PROCEDURE ptest3(y text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest1(y);
CALL ptest1($1);
@@ -89,7 +89,7 @@ SELECT * FROM cp_test;
-- output arguments
CREATE PROCEDURE ptest4a(INOUT a int, INOUT b int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 1, 2;
$$;
@@ -100,7 +100,7 @@ CALL ptest4a(NULL, NULL);
(1 row)
CREATE PROCEDURE ptest4b(INOUT b int, INOUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest4a(a, b); -- error, not supported
$$;
@@ -109,7 +109,7 @@ CONTEXT: SQL function "ptest4b"
DROP PROCEDURE ptest4a;
-- named and default parameters
CREATE OR REPLACE PROCEDURE ptest5(a int, b text, c int default 100)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES(a, b);
INSERT INTO cp_test VALUES(c, b);
@@ -134,21 +134,21 @@ SELECT * FROM cp_test;
-- polymorphic types
CREATE PROCEDURE ptest6(a int, b anyelement)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT NULL::int;
$$;
CALL ptest6(1, 2);
-- collation assignment
CREATE PROCEDURE ptest7(a text, b text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT a = b;
$$;
CALL ptest7(least('a', 'b'), 'a');
-- OUT parameters
CREATE PROCEDURE ptest9(OUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, 'a');
SELECT 1;
@@ -170,13 +170,13 @@ ERROR: sum(integer) is not a procedure
LINE 1: CALL sum(1);
^
HINT: To call a function, use SELECT.
-CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
ERROR: invalid attribute in procedure definition
-LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT I...
+LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQLTEST WINDOW AS $$ INSERT I...
^
-CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
ERROR: invalid attribute in procedure definition
-LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT I...
+LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQLTEST STRICT AS $$ INSERT I...
^
ALTER PROCEDURE ptest1(text) STRICT;
ERROR: invalid attribute in procedure definition
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index ed8c01b8de..65aee00962 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -367,7 +367,7 @@ ERROR: exclusion constraints are not supported on partitioned tables
LINE 3: EXCLUDE USING gist (a WITH &&)
^
-- prevent using prohibited expressions in the key
-CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (retset(a));
@@ -390,7 +390,7 @@ CREATE TABLE partitioned (
a int
) PARTITION BY RANGE ((42));
ERROR: cannot use constant expression as partition key
-CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (const_func());
@@ -427,7 +427,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a, ('unknown'));
ERROR: partition key column 2 has pseudo-type unknown
-- functions in key must be immutable
-CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL;
+CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (immut_func(a));
@@ -459,7 +459,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a);
ERROR: cannot add NO INHERIT constraint to partitioned table "partitioned"
-- some checks after successful creation of a partitioned table
-CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL;
+CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int,
b int,
@@ -1149,7 +1149,7 @@ Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS N
DROP TABLE range_parted4;
-- user-defined operator class in partition key
-CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql
+CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sqltest
AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$;
CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS
OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4),
diff --git a/src/test/regress/expected/create_type.out b/src/test/regress/expected/create_type.out
index 14394cc95c..3f4f6ee65f 100644
--- a/src/test/regress/expected/create_type.out
+++ b/src/test/regress/expected/create_type.out
@@ -131,7 +131,7 @@ HINT: Create the type as a shell type, then create its I/O functions, then do a
CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42);
CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS '
SELECT * FROM default_test;
-' LANGUAGE SQL;
+' LANGUAGE SQLTEST;
SELECT * FROM get_default_test();
f1 | f2
-------+----
diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out
index 411d5c003e..fc56c69d8b 100644
--- a/src/test/regress/expected/domain.out
+++ b/src/test/regress/expected/domain.out
@@ -1067,7 +1067,7 @@ drop domain di;
-- this has caused issues in the past
--
create function sql_is_distinct_from(anyelement, anyelement)
-returns boolean language sql
+returns boolean LANGUAGE SQLTEST
as 'select $1 is distinct from $2 limit 1';
create domain inotnull int
check (sql_is_distinct_from(value, null));
diff --git a/src/test/regress/expected/drop_if_exists.out b/src/test/regress/expected/drop_if_exists.out
index 5e44c2c3ce..e4b45fe0df 100644
--- a/src/test/regress/expected/drop_if_exists.out
+++ b/src/test/regress/expected/drop_if_exists.out
@@ -303,8 +303,8 @@ DROP VIEW IF EXISTS no_such_schema.foo;
NOTICE: schema "no_such_schema" does not exist, skipping
-- Check we receive an ambiguous function error when there are
-- multiple matching functions.
-CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ language sql;
-CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ language sql;
+CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ LANGUAGE SQLTEST;
+CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ LANGUAGE SQLTEST;
DROP FUNCTION test_ambiguous_funcname;
ERROR: function name "test_ambiguous_funcname" is not unique
HINT: Specify the argument list to select the function unambiguously.
diff --git a/src/test/regress/expected/event_trigger.out b/src/test/regress/expected/event_trigger.out
index bdd0ffcdaf..9bcb2a56ab 100644
--- a/src/test/regress/expected/event_trigger.out
+++ b/src/test/regress/expected/event_trigger.out
@@ -20,7 +20,7 @@ ERROR: event trigger functions cannot have declared arguments
CONTEXT: compilation of PL/pgSQL function "test_event_trigger_arg" near line 1
-- should fail, SQL functions cannot be event triggers
create function test_event_trigger_sql() returns event_trigger as $$
-SELECT 1 $$ language sql;
+SELECT 1 $$ LANGUAGE SQLTEST;
ERROR: SQL functions cannot return type event_trigger
-- should fail, no elephant_bootstrap entry point
create event trigger regress_event_trigger on elephant_bootstrap
diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out
index b9e25820bc..d3e4a45b7f 100644
--- a/src/test/regress/expected/foreign_data.out
+++ b/src/test/regress/expected/foreign_data.out
@@ -90,7 +90,7 @@ CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator;
(3 rows)
-- HANDLER related checks
-CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;';
+CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQLTEST AS 'SELECT 1;';
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler; -- ERROR
ERROR: function invalid_fdw_handler must return type fdw_handler
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR
diff --git a/src/test/regress/expected/generated.out b/src/test/regress/expected/generated.out
index ca721d38bf..ad1f9c2f11 100644
--- a/src/test/regress/expected/generated.out
+++ b/src/test/regress/expected/generated.out
@@ -463,7 +463,7 @@ CREATE USER regress_user11;
CREATE TABLE gtest11s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (b * 2) STORED);
INSERT INTO gtest11s VALUES (1, 10), (2, 20);
GRANT SELECT (a, c) ON gtest11s TO regress_user11;
-CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQL;
+CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQLTEST;
REVOKE ALL ON FUNCTION gf1(int) FROM PUBLIC;
CREATE TABLE gtest12s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (gf1(b)) STORED);
INSERT INTO gtest12s VALUES (1, 10), (2, 20);
diff --git a/src/test/regress/expected/guc.out b/src/test/regress/expected/guc.out
index 811f80a097..7dfefc246c 100644
--- a/src/test/regress/expected/guc.out
+++ b/src/test/regress/expected/guc.out
@@ -641,7 +641,7 @@ reset search_path;
--
set work_mem = '3MB';
create function report_guc(text) returns text as
-$$ select current_setting($1) $$ language sql
+$$ select current_setting($1) $$ LANGUAGE SQLTEST
set work_mem = '1MB';
select report_guc('work_mem'), current_setting('work_mem');
report_guc | current_setting
@@ -760,13 +760,13 @@ select current_setting('nosuch.setting', true);
-- function SET options; but not if check_function_bodies is off,
-- because that creates ordering hazards for pg_dump
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
NOTICE: text search configuration "no_such_config" does not exist
ERROR: invalid value for parameter "default_text_search_config": "no_such_config"
set check_function_bodies = off;
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
NOTICE: text search configuration "no_such_config" does not exist
select func_with_bad_set();
diff --git a/src/test/regress/expected/infinite_recurse.out b/src/test/regress/expected/infinite_recurse.out
index aa102fadd8..0f4894b057 100644
--- a/src/test/regress/expected/infinite_recurse.out
+++ b/src/test/regress/expected/infinite_recurse.out
@@ -1,7 +1,7 @@
-- Check that stack depth detection mechanism works and
-- max_stack_depth is not set too high.
create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
+'select infinite_recurse()' LANGUAGE SQLTEST;
-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
-- signal handling that would cause this test to crash if it happened
-- to receive an sinval catchup interrupt while the stack is deep:
diff --git a/src/test/regress/expected/infinite_recurse_1.out b/src/test/regress/expected/infinite_recurse_1.out
index b2c99a0d0d..1c27271a46 100644
--- a/src/test/regress/expected/infinite_recurse_1.out
+++ b/src/test/regress/expected/infinite_recurse_1.out
@@ -1,7 +1,7 @@
-- Check that stack depth detection mechanism works and
-- max_stack_depth is not set too high.
create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
+'select infinite_recurse()' LANGUAGE SQLTEST;
-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
-- signal handling that would cause this test to crash if it happened
-- to receive an sinval catchup interrupt while the stack is deep:
diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out
index 2b68aef654..677e3c9bf8 100644
--- a/src/test/regress/expected/inherit.out
+++ b/src/test/regress/expected/inherit.out
@@ -810,7 +810,7 @@ drop table derived;
drop table base;
create table p1(ff1 int);
create table p2(f1 text);
-create function p2text(p2) returns text as 'select $1.f1' language sql;
+create function p2text(p2) returns text as 'select $1.f1' LANGUAGE SQLTEST;
create table c1(f3 int) inherits(p1,p2);
insert into c1 values(123456789, 'hi', 42);
select p2text(c1.*) from c1;
diff --git a/src/test/regress/expected/insert.out b/src/test/regress/expected/insert.out
index da50ee3b67..fdd7881335 100644
--- a/src/test/regress/expected/insert.out
+++ b/src/test/regress/expected/insert.out
@@ -394,7 +394,7 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
create or replace function part_hashint4_noop(value int4, seed int8)
returns int8 as $$
select value + seed;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_int4_ops
for type int4
using hash as
@@ -403,7 +403,7 @@ function 2 part_hashint4_noop(int4, int8);
create or replace function part_hashtext_length(value text, seed int8)
RETURNS int8 AS $$
select length(coalesce(value, ''))::int8
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_text_ops
for type text
using hash as
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index 81b42c601b..02aef01ce6 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -3494,9 +3494,9 @@ where nt3.id = 1 and ss2.b3;
drop function f_immutable_int4(int);
-- test inlining when function returns composite
create function mki8(bigint, bigint) returns int8_tbl as
-$$select row($1,$2)::int8_tbl$$ language sql;
+$$select row($1,$2)::int8_tbl$$ LANGUAGE SQLTEST;
create function mki4(int) returns int4_tbl as
-$$select row($1)::int4_tbl$$ language sql;
+$$select row($1)::int4_tbl$$ LANGUAGE SQLTEST;
explain (verbose, costs off)
select * from mki8(1,2);
QUERY PLAN
diff --git a/src/test/regress/expected/multirangetypes.out b/src/test/regress/expected/multirangetypes.out
index 04953a5990..656c867d20 100644
--- a/src/test/regress/expected/multirangetypes.out
+++ b/src/test/regress/expected/multirangetypes.out
@@ -2735,7 +2735,7 @@ drop type textrange2;
-- Test polymorphic type system
--
create function anyarray_anymultirange_func(a anyarray, r anymultirange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anymultirange_func(ARRAY[1,2], int4multirange(int4range(10,20)));
anyarray_anymultirange_func
-----------------------------
@@ -2751,16 +2751,16 @@ HINT: No function matches the given name and argument types. You might need to
drop function anyarray_anymultirange_func(anyarray, anymultirange);
-- should fail
create function bogus_func(anyelement)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
-- should fail
create function bogus_func(int)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
create function range_add_bounds(anymultirange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4multirange(int4range(1, 17)));
range_add_bounds
------------------
@@ -2775,7 +2775,7 @@ select range_add_bounds(nummultirange(numrange(1.0001, 123.123)));
create function multirangetypes_sql(q anymultirange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select multirangetypes_sql(int4multirange(int4range(1,10)), ARRAY[2,20]);
multirangetypes_sql
---------------------
@@ -2788,7 +2788,7 @@ LINE 1: select multirangetypes_sql(nummultirange(numrange(1,10)), AR...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
create function anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompatiblemultirange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(int4range(10,20)));
anycompatiblearray_anycompatiblemultirange_func
-------------------------------------------------
@@ -2809,7 +2809,7 @@ LINE 1: select anycompatiblearray_anycompatiblemultirange_func(ARRAY...
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
drop function anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemultirange);
create function anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompatiblemultirange)
- returns anycompatible as 'select lower($1) + lower($2);' language sql;
+ returns anycompatible as 'select lower($1) + lower($2);' LANGUAGE SQLTEST;
select anycompatiblerange_anycompatiblemultirange_func(int4range(1,2), multirange(int4range(10,20)));
anycompatiblerange_anycompatiblemultirange_func
-------------------------------------------------
@@ -2825,7 +2825,7 @@ HINT: No function matches the given name and argument types. You might need to
drop function anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange, anycompatiblemultirange);
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
--
@@ -2902,7 +2902,7 @@ reset enable_sort;
--
-- infer anymultirange from anymultirange
create function mr_outparam_succeed(i anymultirange, out r anymultirange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed(int4multirange(int4range(1,2)));
r | t
---------+-----
@@ -2911,7 +2911,7 @@ select * from mr_outparam_succeed(int4multirange(int4range(1,2)));
-- infer anyarray from anymultirange
create function mr_outparam_succeed2(i anymultirange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed2(int4multirange(int4range(1,2)));
r | t
-----+-----
@@ -2920,7 +2920,7 @@ select * from mr_outparam_succeed2(int4multirange(int4range(1,2)));
-- infer anyrange from anymultirange
create function mr_outparam_succeed3(i anymultirange, out r anyrange, out t text)
- as $$ select range_merge($1), 'foo'::text $$ language sql;
+ as $$ select range_merge($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed3(int4multirange(int4range(1,2)));
r | t
-------+-----
@@ -2929,7 +2929,7 @@ select * from mr_outparam_succeed3(int4multirange(int4range(1,2)));
-- infer anymultirange from anyrange
create function mr_outparam_succeed4(i anyrange, out r anymultirange, out t text)
- as $$ select multirange($1), 'foo'::text $$ language sql;
+ as $$ select multirange($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed4(int4range(1,2));
r | t
---------+-----
@@ -2938,7 +2938,7 @@ select * from mr_outparam_succeed4(int4range(1,2));
-- infer anyelement from anymultirange
create function mr_inoutparam_succeed(out i anyelement, inout r anymultirange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from mr_inoutparam_succeed(int4multirange(int4range(1,2)));
i | r
---+---------
@@ -2947,7 +2947,7 @@ select * from mr_inoutparam_succeed(int4multirange(int4range(1,2)));
-- infer anyelement+anymultirange from anyelement+anymultirange
create function mr_table_succeed(i anyelement, r anymultirange) returns table(i anyelement, r anymultirange)
- as $$ select $1, $2 $$ language sql;
+ as $$ select $1, $2 $$ LANGUAGE SQLTEST;
select * from mr_table_succeed(123, int4multirange(int4range(1,11)));
i | r
-----+----------
@@ -2965,16 +2965,16 @@ select mr_polymorphic(int4range(1, 4));
-- should fail
create function mr_outparam_fail(i anyelement, out r anymultirange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
--should fail
create function mr_inoutparam_fail(inout i anyelement, out r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
--should fail
create function mr_table_fail(i anyelement) returns table(i anyelement, r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
diff --git a/src/test/regress/expected/object_address.out b/src/test/regress/expected/object_address.out
index 388097a695..a03756e41b 100644
--- a/src/test/regress/expected/object_address.out
+++ b/src/test/regress/expected/object_address.out
@@ -32,14 +32,14 @@ CREATE DOMAIN addr_nsp.gendomain AS int4 CONSTRAINT domconstr CHECK (value > 0);
CREATE FUNCTION addr_nsp.trig() RETURNS TRIGGER LANGUAGE plpgsql AS $$ BEGIN END; $$;
CREATE TRIGGER t BEFORE INSERT ON addr_nsp.gentable FOR EACH ROW EXECUTE PROCEDURE addr_nsp.trig();
CREATE POLICY genpol ON addr_nsp.gentable;
-CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQL AS $$ $$;
+CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQLTEST AS $$ $$;
CREATE SERVER "integer" FOREIGN DATA WRAPPER addr_fdw;
CREATE USER MAPPING FOR regress_addr_user SERVER "integer";
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regress_addr_user;
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM regress_addr_user;
-- this transform would be quite unsafe to leave lying around,
-- except that the SQL language pays no attention to transforms:
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
-- suppress warning that depends on wal_level
@@ -482,7 +482,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
policy | | | genpol on addr_nsp.gentable | t
statistics object | addr_nsp | gentable_stat | addr_nsp.gentable_stat | t
collation | pg_catalog | "default" | pg_catalog."default" | t
- transform | | | for integer on language sql | t
+ transform | | | for integer on LANGUAGE SQLTEST | t
text search dictionary | addr_nsp | addr_ts_dict | addr_nsp.addr_ts_dict | t
text search parser | addr_nsp | addr_ts_prs | addr_nsp.addr_ts_prs | t
text search configuration | addr_nsp | addr_ts_conf | addr_nsp.addr_ts_conf | t
@@ -569,7 +569,7 @@ WITH objects (classid, objid, objsubid) AS (VALUES
('pg_policy'::regclass, 0, 0), -- no policy
('pg_publication'::regclass, 0, 0), -- no publication
('pg_publication_rel'::regclass, 0, 0), -- no publication relation
- ('pg_subscription'::regclass, 0, 0), -- no subscription
+ ('pg_sub'::regclass, 0, 0), -- no subscription
('pg_transform'::regclass, 0, 0) -- no transformation
)
SELECT ROW(pg_identify_object(objects.classid, objects.objid, objects.objsubid))
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out
index 6ea169d9ad..9f044f2376 100644
--- a/src/test/regress/expected/plpgsql.out
+++ b/src/test/regress/expected/plpgsql.out
@@ -4358,14 +4358,14 @@ end;
$$ language plpgsql;
-- "limit" is to prevent this from being inlined
create function sql_recurse(float8) returns float8 as
-$$ select recurse($1) limit 1; $$ language sql;
+$$ select recurse($1) limit 1; $$ LANGUAGE SQLTEST;
select recurse(10);
recurse
---------
0
(1 row)
-create function error1(text) returns text language sql as
+create function error1(text) returns text LANGUAGE SQLTEST as
$$ SELECT relname::text FROM pg_class c WHERE c.oid = $1::regclass $$;
create function error2(p_name_table text) returns text language plpgsql as $$
begin
@@ -4391,7 +4391,7 @@ drop function error1(text);
-- Test for proper handling of cast-expression caching
create function sql_to_date(integer) returns date as $$
select $1::text::date
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
create cast (integer as date) with function sql_to_date(integer) as assignment;
create function cast_invoker(integer) returns date as $$
begin
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index 772345584f..648132db4e 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -4,7 +4,7 @@
--
create function polyf(x anyelement) returns anyelement as $$
select x + 1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
int | num
-----+-----
@@ -23,7 +23,7 @@ CONTEXT: SQL function "polyf" during inlining
drop function polyf(x anyelement);
create function polyf(x anyelement) returns anyarray as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
int | num
---------+-----------
@@ -33,7 +33,7 @@ select polyf(42) as int, polyf(4.5) as num;
drop function polyf(x anyelement);
create function polyf(x anyarray) returns anyelement as $$
select x[1]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
int | num
-----+-----
@@ -45,7 +45,7 @@ ERROR: cannot determine element type of "anyarray" argument
drop function polyf(x anyarray);
create function polyf(x anyarray) returns anyarray as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
int | num
-------+-----------
@@ -59,12 +59,12 @@ drop function polyf(x anyarray);
-- fail, can't infer type:
create function polyf(x anyelement) returns anyrange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
create function polyf(x anyrange) returns anyarray as $$
select array[lower(x), upper(x)]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num;
int | num
---------+-----------
@@ -74,7 +74,7 @@ select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num;
drop function polyf(x anyrange);
create function polyf(x anycompatible, y anycompatible) returns anycompatiblearray as $$
select array[x, y]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(2, 4) as int, polyf(2, 4.5) as num;
int | num
-------+---------
@@ -84,7 +84,7 @@ select polyf(2, 4) as int, polyf(2, 4.5) as num;
drop function polyf(x anycompatible, y anycompatible);
create function polyf(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), 11, 2::smallint) as int, polyf(float8range(4.5, 7.8), 7.8, 11::real) as num;
int | num
--------------+------------------
@@ -99,7 +99,7 @@ HINT: No function matches the given name and argument types. You might need to
drop function polyf(x anycompatiblerange, y anycompatible, z anycompatible);
create function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), 11, 2::smallint) as int, polyf(multirange(float8range(4.5, 7.8)), 7.8, 11::real) as num;
int | num
--------------+------------------
@@ -115,12 +115,12 @@ drop function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible)
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblerange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function polyf(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), array[11]) as int, polyf(float8range(4.5, 7.8), array[7]) as num;
int | num
---------+-----------
@@ -131,12 +131,12 @@ drop function polyf(x anycompatiblerange, y anycompatiblearray);
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblemultirange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblemultirange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function polyf(x anycompatiblemultirange, y anycompatiblearray) returns anycompatiblemultirange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), array[11]) as int, polyf(multirange(float8range(4.5, 7.8)), array[7]) as num;
int | num
-----------+-------------
@@ -149,7 +149,7 @@ create function polyf(a anyelement, b anyarray,
OUT x anyarray, OUT y anycompatiblearray)
as $$
select a || b, array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x), y, pg_typeof(y)
from polyf(11, array[1, 2], 42, 34.5);
x | pg_typeof | y | pg_typeof
@@ -216,31 +216,31 @@ drop function polyf(a anyelement, b anyarray,
-- functions, i.e. tf arg1 and tf return type must match
-- polymorphic single arg transfn
CREATE FUNCTION stfp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- non-polymorphic single arg transfn
CREATE FUNCTION stfnp(int[]) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- dual polymorphic transfn
CREATE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- dual non-polymorphic transfn
CREATE FUNCTION tfnp(int[],int) RETURNS int[] AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- arg1 only polymorphic transfn
CREATE FUNCTION tf1p(anyarray,int) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- arg2 only polymorphic transfn
CREATE FUNCTION tf2p(int[],anyelement) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- multi-arg polymorphic
CREATE FUNCTION sum3(anyelement,anyelement,anyelement) returns anyelement AS
-'select $1+$2+$3' language sql strict;
+'select $1+$2+$3' LANGUAGE SQLTEST strict;
-- finalfn polymorphic
CREATE FUNCTION ffp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- finalfn non-polymorphic
CREATE FUNCTION ffnp(int[]) returns int[] as
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- Try to cover all the possible states:
--
-- Note: in Cases 1 & 2, we are trying to return P. Therefore, if the transfn
@@ -731,7 +731,7 @@ begin
return $1;
end$$ language plpgsql;
create function sql_if(bool, anyelement, anyelement) returns anyelement as $$
-select case when $1 then $2 else $3 end $$ language sql;
+select case when $1 then $2 else $3 end $$ LANGUAGE SQLTEST;
-- Note this would fail with integer overflow, never mind wrong bleat() output,
-- if the CASE expression were not successfully inlined
select f1, sql_if(f1 > 0, bleat(f1), bleat(f1 + 1)) from int4_tbl;
@@ -818,9 +818,9 @@ create aggregate build_group(int8, integer) (
);
-- check proper resolution of data types for polymorphic transfn/finalfn
create function first_el_transfn(anyarray, anyelement) returns anyarray as
-'select $1 || $2' language sql immutable;
+'select $1 || $2' LANGUAGE SQLTEST immutable;
create function first_el(anyarray) returns anyelement as
-'select $1[1]' language sql strict immutable;
+'select $1[1]' LANGUAGE SQLTEST strict immutable;
create aggregate first_el_agg_f8(float8) (
SFUNC = array_append,
STYPE = float8[],
@@ -901,7 +901,7 @@ ERROR: cannot accept a value of type anyrange
-- test variadic polymorphic functions
create function myleast(variadic anyarray) returns anyelement as $$
select min($1[i]) from generate_subscripts($1,1) g(i)
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select myleast(10, 1, 20, 33);
myleast
---------
@@ -948,7 +948,7 @@ select myleast(variadic array[]::int[]);
-- an example with some ordinary arguments too
create function concat(text, variadic anyarray) returns text as $$
select array_to_string($2, $1);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select concat('%', 1, 2, 3, 4, 5);
concat
-----------
@@ -977,7 +977,7 @@ drop function concat(text, anyarray);
-- mix variadic with anyelement
create function formarray(anyelement, variadic anyarray) returns anyarray as $$
select array_prepend($1, $2);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select formarray(1,2,3,4,5);
formarray
-------------
@@ -1065,7 +1065,7 @@ select pg_typeof(myleast(10, 1, 20, 33)); -- polymorphic input
-- test basic functionality
create function dfunc(a int = 1, int = 2) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
-------
@@ -1097,12 +1097,12 @@ drop function dfunc(int, int); -- ok
-- fail: defaults must be at end of argument list
create function dfunc(a int = 1, b int) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: input parameters after one with a default value must also have defaults
-- however, this should work:
create function dfunc(a int = 1, out sum int, b int = 2) as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
-------
@@ -1121,7 +1121,7 @@ drop function dfunc(int, int);
-- check implicit coercion
create function dfunc(a int DEFAULT 1.0, int DEFAULT '-1') returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
-------
@@ -1130,7 +1130,7 @@ select dfunc();
create function dfunc(a text DEFAULT 'Hello', b text DEFAULT 'World') returns text as $$
select $1 || ', ' || $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(); -- fail: which dfunc should be called? int or text
ERROR: function dfunc() is not unique
LINE 1: select dfunc();
@@ -1164,10 +1164,10 @@ drop function dfunc(int, int);
drop function dfunc(text, text);
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2, int = 3, int = 4) returns int as $$
select 4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- Now, dfunc(nargs = 2) and dfunc(nargs = 4) are ambiguous when called
-- with 0 to 2 arguments.
select dfunc(); -- fail
@@ -1202,12 +1202,12 @@ drop function dfunc(int, int, int, int);
-- default values are not allowed for output parameters
create function dfunc(out int = 20) returns int as $$
select 1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: only input parameters can have default values
-- polymorphic parameter test
create function dfunc(anyelement = 'World'::text) returns text as $$
select 'Hello, ' || $1::text;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
--------------
@@ -1235,7 +1235,7 @@ select dfunc('City'::text);
drop function dfunc(anyelement);
-- check defaults for variadics
create function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- fail
ERROR: function dfunc() does not exist
LINE 1: select dfunc();
@@ -1254,7 +1254,7 @@ select dfunc(10,20);
(1 row)
create or replace function dfunc(a variadic int[] default array[]::int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- now ok
dfunc
-------
@@ -1275,7 +1275,7 @@ select dfunc(10,20);
-- can't remove the default once it exists
create or replace function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
ERROR: cannot remove parameter defaults from existing function
HINT: Use DROP FUNCTION dfunc(integer[]) first.
\df dfunc
@@ -1289,13 +1289,13 @@ drop function dfunc(a variadic int[]);
-- Ambiguity should be reported only if there's not a better match available
create function dfunc(int = 1, int = 2, int = 3) returns int as $$
select 3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(text) returns text as $$
select $1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- dfunc(narg=2) and dfunc(narg=3) are ambiguous
select dfunc(1); -- fail
ERROR: function dfunc(integer) is not unique
@@ -1318,7 +1318,7 @@ drop function dfunc(text);
create function dfunc(a int, b int, c int = 0, d int = 0)
returns table (a int, b int, c int, d int) as $$
select $1, $2, $3, $4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc(10,20,30)).*;
a | b | c | d
----+----+----+---
@@ -1394,7 +1394,7 @@ drop function dfunc(int, int, int, int);
create function dfunc(a varchar, b numeric, c date = current_date)
returns table (a varchar, b numeric, c date) as $$
select $1, $2, $3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc('Hello World', 20, '2009-07-25'::date)).*;
a | b | c
-------------+----+------------
@@ -1435,7 +1435,7 @@ drop function dfunc(varchar, numeric, date);
create function dfunc(a varchar = 'def a', out _a varchar, c numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc()).*;
_a | _c
-------+----
@@ -1488,27 +1488,27 @@ select * from dfunc(c := 100);
create or replace function dfunc(a varchar = 'def a', out _a varchar, x numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot change name of input parameter "c"
HINT: Use DROP FUNCTION dfunc(character varying,numeric) first.
create or replace function dfunc(a varchar = 'def a', out _a varchar, numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot change name of input parameter "c"
HINT: Use DROP FUNCTION dfunc(character varying,numeric) first.
drop function dfunc(varchar, numeric);
--fail, named parameters are not unique
-create function testpolym(a int, a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(a int, a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-create function testpolym(a int, inout a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-- valid
-create function testpolym(a int, out a int) returns int as $$ select $1;$$ language sql;
+create function testpolym(a int, out a int) returns int as $$ select $1;$$ LANGUAGE SQLTEST;
select testpolym(37);
testpolym
-----------
@@ -1516,7 +1516,7 @@ select testpolym(37);
(1 row)
drop function testpolym(int);
-create function testpolym(a int) returns table(a int) as $$ select $1;$$ language sql;
+create function testpolym(a int) returns table(a int) as $$ select $1;$$ LANGUAGE SQLTEST;
select * from testpolym(37);
a
----
@@ -1528,7 +1528,7 @@ drop function testpolym(int);
create function dfunc(a anyelement, b anyelement = null, flag bool = true)
returns anyelement as $$
select case when $3 then $1 else $2 end;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(1,2);
dfunc
-------
@@ -1749,7 +1749,7 @@ drop function dfunc(anyelement, anyelement, bool);
create function anyctest(anycompatible, anycompatible)
returns anycompatible as $$
select greatest($1, $2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
----+-----------
@@ -1777,7 +1777,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatible)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
---------+-----------
@@ -1799,7 +1799,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatiblearray)
returns anycompatiblearray as $$
select array[$1] || $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[12]) x;
x | pg_typeof
---------+-----------
@@ -1838,7 +1838,7 @@ drop function anyctest(anycompatible, anycompatiblearray);
create function anyctest(anycompatible, anycompatiblerange)
returns anycompatiblerange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, int4range(4,7)) x;
x | pg_typeof
-------+-----------
@@ -1867,7 +1867,7 @@ drop function anyctest(anycompatible, anycompatiblerange);
create function anyctest(anycompatiblerange, anycompatiblerange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(int4range(11,12), int4range(4,7)) x;
x | pg_typeof
----+-----------
@@ -1884,13 +1884,13 @@ drop function anyctest(anycompatiblerange, anycompatiblerange);
create function anyctest(anycompatible)
returns anycompatiblerange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function anyctest(anycompatible, anycompatiblemultirange)
returns anycompatiblemultirange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, multirange(int4range(4,7))) x;
x | pg_typeof
---------+----------------
@@ -1919,7 +1919,7 @@ drop function anyctest(anycompatible, anycompatiblemultirange);
create function anyctest(anycompatiblemultirange, anycompatiblemultirange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(int4range(4,7))) x;
x | pg_typeof
----+-----------
@@ -1936,13 +1936,13 @@ drop function anyctest(anycompatiblemultirange, anycompatiblemultirange);
create function anyctest(anycompatible)
returns anycompatiblemultirange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblemultirange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function anyctest(anycompatiblenonarray, anycompatiblenonarray)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
---------+-----------
@@ -1965,7 +1965,7 @@ create function anyctest(a anyelement, b anyarray,
c anycompatible, d anycompatible)
returns anycompatiblearray as $$
select array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[1, 2], 42, 34.5) x;
x | pg_typeof
-----------+-----------
@@ -1994,7 +1994,7 @@ drop function anyctest(a anyelement, b anyarray,
create function anyctest(variadic anycompatiblearray)
returns anycompatiblearray as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
---------+-----------
diff --git a/src/test/regress/expected/portals.out b/src/test/regress/expected/portals.out
index dc0d2ef7dd..09c07bd9d4 100644
--- a/src/test/regress/expected/portals.out
+++ b/src/test/regress/expected/portals.out
@@ -779,7 +779,7 @@ BEGIN;
CREATE FUNCTION declares_cursor(text)
RETURNS void
AS 'DECLARE c CURSOR FOR SELECT stringu1 FROM tenk1 WHERE stringu1 LIKE $1;'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT declares_cursor('AB%');
declares_cursor
-----------------
@@ -814,9 +814,9 @@ ROLLBACK;
--
create temp table tt1(f1 int);
create function count_tt1_v() returns int8 as
-'select count(*) from tt1' language sql volatile;
+'select count(*) from tt1' LANGUAGE SQLTEST volatile;
create function count_tt1_s() returns int8 as
-'select count(*) from tt1' language sql stable;
+'select count(*) from tt1' LANGUAGE SQLTEST stable;
begin;
insert into tt1 values(1);
declare c1 cursor for select count_tt1_v(), count_tt1_s();
@@ -1359,7 +1359,7 @@ DROP TABLE cursor;
-- per bug report in 8336843.9833.1399385291498.JavaMail.root@quick
begin;
create function nochange(int) returns int
- as 'select $1 limit 1' language sql stable;
+ as 'select $1 limit 1' LANGUAGE SQLTEST stable;
declare c cursor for select * from int8_tbl limit nochange(3);
fetch all from c;
q1 | q2
diff --git a/src/test/regress/expected/privileges.out b/src/test/regress/expected/privileges.out
index 7754c20db4..6b01922846 100644
--- a/src/test/regress/expected/privileges.out
+++ b/src/test/regress/expected/privileges.out
@@ -737,18 +737,18 @@ END;
-- privileges on functions, languages
-- switch to superuser
\c -
-REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user1; -- ok
+REVOKE ALL PRIVILEGES ON LANGUAGE sqltest FROM PUBLIC;
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user1; -- ok
GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
ERROR: language "c" is not trusted
DETAIL: GRANT and REVOKE are not allowed on untrusted languages, because only superusers can use untrusted languages.
SET SESSION AUTHORIZATION regress_priv_user1;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user2; -- fail
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user2; -- fail
WARNING: no privileges were granted for "sql"
-CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql;
-CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest;
+CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE priv_testagg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sql;
+CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sqltest;
REVOKE ALL ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) TO regress_priv_user2;
REVOKE ALL ON FUNCTION priv_testproc1(int) FROM PUBLIC; -- fail, not a function
@@ -768,7 +768,7 @@ GRANT ALL PRIVILEGES ON FUNCTION priv_testagg1(int) TO regress_priv_user4;
GRANT ALL PRIVILEGES ON PROCEDURE priv_testproc1(int) TO regress_priv_user4;
CREATE FUNCTION priv_testfunc4(boolean) RETURNS text
AS 'select col1 from atest2 where col2 = $1;'
- LANGUAGE sql SECURITY DEFINER;
+ LANGUAGE sqltest SECURITY DEFINER;
GRANT EXECUTE ON FUNCTION priv_testfunc4(boolean) TO regress_priv_user3;
SET SESSION AUTHORIZATION regress_priv_user2;
SELECT priv_testfunc1(5), priv_testfunc2(5); -- ok
@@ -777,8 +777,8 @@ SELECT priv_testfunc1(5), priv_testfunc2(5); -- ok
10 | 15
(1 row)
-CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail
-ERROR: permission denied for language sql
+CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest; -- fail
+ERROR: permission denied for LANGUAGE SQLTEST
SELECT priv_testagg1(x) FROM (VALUES (1), (2), (3)) _(x); -- ok
priv_testagg1
---------------
@@ -824,7 +824,7 @@ ERROR: must be owner of procedure priv_testproc1
\c -
DROP FUNCTION priv_testfunc1(int); -- ok
-- restore to sanity
-GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
+GRANT ALL PRIVILEGES ON LANGUAGE sqltest TO PUBLIC;
-- verify privilege checks on array-element coercions
BEGIN;
SELECT '{1}'::int4[]::int8[];
@@ -866,14 +866,14 @@ ERROR: permission denied for type priv_testdomain1
CREATE DOMAIN priv_testdomain2a AS priv_testdomain1;
ERROR: permission denied for type priv_testdomain1
CREATE DOMAIN priv_testdomain3a AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3a) WITH FUNCTION castfunc(int);
ERROR: permission denied for type priv_testdomain1
DROP FUNCTION castfunc(int) CASCADE;
DROP DOMAIN priv_testdomain3a;
-CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
ERROR: permission denied for type priv_testdomain1
-CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
ERROR: permission denied for type priv_testdomain1
CREATE OPERATOR !+! (PROCEDURE = int4pl, LEFTARG = priv_testdomain1, RIGHTARG = priv_testdomain1);
ERROR: permission denied for type priv_testdomain1
@@ -904,11 +904,11 @@ SET SESSION AUTHORIZATION regress_priv_user2;
CREATE AGGREGATE priv_testagg1b(priv_testdomain1) (sfunc = int4_sum, stype = bigint);
CREATE DOMAIN priv_testdomain2b AS priv_testdomain1;
CREATE DOMAIN priv_testdomain3b AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3b) WITH FUNCTION castfunc(int);
WARNING: cast will be ignored because the source data type is a domain
-CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
-CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
CREATE OPERATOR !! (PROCEDURE = priv_testfunc5b, RIGHTARG = priv_testdomain1);
CREATE TABLE test5b (a int, b priv_testdomain1);
CREATE TABLE test6b OF priv_testtype1;
@@ -1330,9 +1330,9 @@ SELECT has_table_privilege('regress_priv_user1', 'atest4', 'SELECT WITH GRANT OP
\c -
CREATE ROLE regress_sro_user;
SET SESSION AUTHORIZATION regress_sro_user;
-CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sql AS
+CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sqltest AS
'GRANT regress_priv_group2 TO regress_sro_user';
-CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'DECLARE c CURSOR WITH HOLD FOR SELECT unwanted_grant(); SELECT true';
-- REFRESH of this MV will queue a GRANT at end of transaction
CREATE MATERIALIZED VIEW sro_mv AS SELECT mv_action() WITH NO DATA;
@@ -1351,7 +1351,7 @@ CREATE FUNCTION sro_trojan() RETURNS trigger LANGUAGE plpgsql AS
CREATE CONSTRAINT TRIGGER t AFTER INSERT ON sro_trojan_table
INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE sro_trojan();
-- Now, REFRESH will issue such an INSERT, queueing the GRANT
-CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'INSERT INTO sro_trojan_table DEFAULT VALUES; SELECT true';
REFRESH MATERIALIZED VIEW sro_mv;
ERROR: cannot fire deferred trigger within security-restricted operation
@@ -1370,7 +1370,7 @@ DROP OWNED BY regress_sro_user;
DROP ROLE regress_sro_user;
-- Admin options
SET SESSION AUTHORIZATION regress_priv_user4;
-CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: had ADMIN OPTION
SET ROLE regress_priv_group2;
@@ -1392,7 +1392,7 @@ ERROR: must have admin option on role "regress_priv_group2"
SET SESSION AUTHORIZATION regress_priv_group2;
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: a role can self-admin
NOTICE: role "regress_priv_user5" is already a member of role "regress_priv_group2"
-CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
SELECT dogrant_fails(); -- fails: no self-admin in SECURITY DEFINER
ERROR: must have admin option on role "regress_priv_group2"
@@ -1773,9 +1773,9 @@ SELECT has_schema_privilege('regress_priv_user2', 'testns5', 'CREATE'); -- no
(1 row)
SET ROLE regress_priv_user1;
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- no
has_function_privilege
------------------------
@@ -1796,11 +1796,11 @@ SELECT has_function_privilege('regress_priv_user2', 'testns.bar()', 'EXECUTE');
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT EXECUTE ON ROUTINES to public;
DROP FUNCTION testns.foo();
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
DROP AGGREGATE testns.agg1(int);
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
DROP PROCEDURE testns.bar();
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- yes
has_function_privilege
------------------------
@@ -1899,9 +1899,9 @@ SELECT has_table_privilege('regress_priv_user1', 'testns.t2', 'SELECT'); -- fals
f
(1 row)
-CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE testns.priv_testagg(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sql;
+CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user1', 'testns.priv_testfunc(int)', 'EXECUTE'); -- true by default
has_function_privilege
------------------------
@@ -2086,7 +2086,7 @@ SELECT lo_unlink(oid) FROM pg_largeobject_metadata WHERE oid >= 1000 AND oid < 3
DROP GROUP regress_priv_group1;
DROP GROUP regress_priv_group2;
-- these are needed to clean up permissions
-REVOKE USAGE ON LANGUAGE sql FROM regress_priv_user1;
+REVOKE USAGE ON LANGUAGE sqltest FROM regress_priv_user1;
DROP OWNED BY regress_priv_user1;
DROP USER regress_priv_user1;
DROP USER regress_priv_user2;
diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out
index 5bbd5f6c0b..3621a29cf1 100644
--- a/src/test/regress/expected/rangefuncs.out
+++ b/src/test/regress/expected/rangefuncs.out
@@ -2,7 +2,7 @@ CREATE TABLE rngfunc2(rngfuncid int, f2 int);
INSERT INTO rngfunc2 VALUES(1, 11);
INSERT INTO rngfunc2 VALUES(2, 22);
INSERT INTO rngfunc2 VALUES(1, 111);
-CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQL;
+CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQLTEST;
-- function with ORDINALITY
select * from rngfunct(1) with ordinality as z(a,b,ord);
a | b | ord
@@ -340,7 +340,7 @@ INSERT INTO rngfunc VALUES(1,1,'Joe');
INSERT INTO rngfunc VALUES(1,2,'Ed');
INSERT INTO rngfunc VALUES(2,1,'Mary');
-- sql, proretset = f, prorettype = b
-CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc1(1) AS t1;
t1
----
@@ -370,7 +370,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc2(1) AS t1;
t1
----
@@ -404,7 +404,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc3(1) AS t1;
t1
-----
@@ -438,7 +438,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = c
-CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc4(1) AS t1;
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -468,7 +468,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = c
-CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc5(1) AS t1;
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -502,7 +502,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = record
-CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc6(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -535,7 +535,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = record
-CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc7(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -697,7 +697,7 @@ DROP TABLE rngfunc;
CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq1;
CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq2;
CREATE TYPE rngfunc_rescan_t AS (i integer, s bigint);
-CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQL;
+CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQLTEST;
-- plpgsql functions use materialize mode
CREATE FUNCTION rngfunc_mat(int,int) RETURNS setof rngfunc_rescan_t AS 'begin for i in $1..$2 loop return next (i, nextval(''rngfunc_rescan_seq2'')); end loop; end;' LANGUAGE plpgsql;
--invokes ExecReScanFunctionScan - all these cases should materialize the function only once
@@ -1424,7 +1424,7 @@ DROP SEQUENCE rngfunc_rescan_seq2;
-- Test cases involving OUT parameters
--
CREATE FUNCTION rngfunc(in f1 int, out f2 int)
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
SELECT rngfunc(42);
rngfunc
---------
@@ -1445,22 +1445,22 @@ SELECT * FROM rngfunc(42) AS p(x);
-- explicit spec of return type is OK
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
-- error, wrong result type
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS float
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
ERROR: function result type must be integer because of OUT parameters
-- with multiple OUT params you must get a RECORD result
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
ERROR: function result type must be record because of OUT parameters
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text)
RETURNS record
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
ERROR: cannot change return type of existing function
HINT: Use DROP FUNCTION rngfunc(integer) first.
CREATE OR REPLACE FUNCTION rngfuncr(in f1 int, out f2 int, out text)
-AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncr(f1) FROM int4_tbl;
f1 | rngfuncr
-------------+----------------------------
@@ -1484,7 +1484,7 @@ SELECT * FROM rngfuncr(42) AS p(a,b);
(1 row)
CREATE OR REPLACE FUNCTION rngfuncb(in f1 int, inout f2 int, out text)
-AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncb(f1, f1/2) FROM int4_tbl;
f1 | rngfuncb
-------------+----------------------------
@@ -1515,7 +1515,7 @@ DROP FUNCTION rngfuncb(in f1 int, inout f2 int);
-- For my next trick, polymorphic OUT parameters
--
CREATE FUNCTION dup (f1 anyelement, f2 out anyelement, f3 out anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
dup
----------------
@@ -1538,13 +1538,13 @@ SELECT * FROM dup('xyz'::text);
-- fails, as we are attempting to rename first argument
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
ERROR: cannot change name of input parameter "f1"
HINT: Use DROP FUNCTION dup(anyelement) first.
DROP FUNCTION dup(anyelement);
-- equivalent behavior, though different name exposed for input arg
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
dup
----------------
@@ -1554,11 +1554,11 @@ SELECT dup(22);
DROP FUNCTION dup(anyelement);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 int, out f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
ERROR: cannot determine result data type
DETAIL: A result of type anyelement requires at least one input of type anyelement, anyarray, anynonarray, anyenum, anyrange, or anymultirange.
CREATE FUNCTION dup (f1 anycompatible, f2 anycompatiblearray, f3 out anycompatible, f4 out anycompatiblearray)
-AS 'select $1, $2' LANGUAGE sql;
+AS 'select $1, $2' LANGUAGE sqltest;
SELECT dup(22, array[44]);
dup
-----------
@@ -1585,7 +1585,7 @@ SELECT *, pg_typeof(f3), pg_typeof(f4) FROM dup(22, array[44::bigint]);
DROP FUNCTION dup(f1 anycompatible, f2 anycompatiblearray);
CREATE FUNCTION dup (f1 anycompatiblerange, f2 out anycompatible, f3 out anycompatiblearray, f4 out anycompatiblerange)
-AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sql;
+AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sqltest;
SELECT dup(int4range(4,7));
dup
---------------------
@@ -1607,7 +1607,7 @@ SELECT dup(textrange('aaa', 'bbb'));
DROP FUNCTION dup(f1 anycompatiblerange);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 anyarray, out f2 anycompatible, out f3 anycompatiblearray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatible requires at least one input of type anycompatible, anycompatiblearray, anycompatiblenonarray, or anycompatiblerange.
--
@@ -1615,7 +1615,7 @@ DETAIL: A result of type anycompatible requires at least one input of type anyc
--
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a int)
-AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sql;
+AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc();
a
---
@@ -1631,7 +1631,7 @@ CREATE OR REPLACE FUNCTION rngfunc(int)
RETURNS TABLE(a int, b int)
AS $$ SELECT a, b
FROM generate_series(1,$1) a(a),
- generate_series(1,$1) b(b) $$ LANGUAGE sql;
+ generate_series(1,$1) b(b) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc(3);
a | b
---+---
@@ -1650,7 +1650,7 @@ DROP FUNCTION rngfunc(int);
-- case that causes change of typmod knowledge during inlining
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a varchar(5))
-AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sql STABLE;
+AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sqltest STABLE;
SELECT * FROM rngfunc() GROUP BY 1;
a
-------
@@ -1664,7 +1664,7 @@ DROP FUNCTION rngfunc();
create temp table tt(f1 serial, data text);
create function insert_tt(text) returns int as
$$ insert into tt(data) values($1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('foo');
insert_tt
-----------
@@ -1687,7 +1687,7 @@ select * from tt;
-- insert will execute to completion even if function needs just 1 row
create or replace function insert_tt(text) returns int as
$$ insert into tt(data) values($1),($1||$1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('fool');
insert_tt
-----------
@@ -1706,7 +1706,7 @@ select * from tt;
-- setof does what's expected
create or replace function insert_tt2(text,text) returns setof int as
$$ insert into tt(data) values($1),($2) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt2('foolish','barrish');
insert_tt2
------------
@@ -1832,7 +1832,7 @@ select * from tt_log;
-- test case for a whole-row-variable bug
create function rngfunc1(n integer, out a text, out b text)
returns setof record
- language sql
+ LANGUAGE SQLTEST
as $$ select 'foo ' || i, 'bar ' || i from generate_series(1,$1) i $$;
set work_mem='64kB';
select t.a, t, t.a from rngfunc1(10000) t limit 1;
@@ -1854,7 +1854,7 @@ drop function rngfunc1(n integer);
-- the actual record type ...
create function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql strict immutable;
+$$ LANGUAGE SQLTEST strict immutable;
select array_to_set(array['one', 'two']);
array_to_set
--------------
@@ -1899,7 +1899,7 @@ explain (verbose, costs off)
-- but without, it can be:
create or replace function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select array_to_set(array['one', 'two']);
array_to_set
--------------
@@ -1937,7 +1937,7 @@ explain (verbose, costs off)
create temp table rngfunc(f1 int8, f2 int8);
create function testrngfunc() returns record as $$
insert into rngfunc values (1,2) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
testrngfunc
-------------
@@ -1957,7 +1957,7 @@ LINE 1: select * from testrngfunc();
drop function testrngfunc();
create function testrngfunc() returns setof record as $$
insert into rngfunc values (1,2), (3,4) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
testrngfunc
-------------
@@ -1981,7 +1981,7 @@ drop function testrngfunc();
create type rngfunc_type as (f1 numeric(35,6), f2 numeric(35,2));
create function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2013,7 +2013,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2046,7 +2046,7 @@ select * from testrngfunc();
drop function testrngfunc();
create function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2078,7 +2078,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2111,7 +2111,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 1, 2 union select 3, 4 order by 1;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2177,7 +2177,7 @@ insert into users values ('id2',2,'email2',true,12,true);
alter table users drop column todrop;
create or replace function get_first_user() returns users as
$$ SELECT * FROM users ORDER BY userid LIMIT 1; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_first_user();
get_first_user
-------------------
@@ -2192,7 +2192,7 @@ SELECT * FROM get_first_user();
create or replace function get_users() returns setof users as
$$ SELECT * FROM users ORDER BY userid; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_users();
get_users
---------------------
@@ -2263,7 +2263,7 @@ drop table users;
-- check behavior with type coercion required for a set-op
create or replace function rngfuncbar() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar ; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select rngfuncbar();
rngfuncbar
------------
@@ -2294,7 +2294,7 @@ explain (verbose, costs off) select * from rngfuncbar();
drop function rngfuncbar();
-- check handling of a SQL function with multiple OUT params (bug #5777)
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1) $$ language sql;
+$$ select (1, 2.1) $$ LANGUAGE SQLTEST;
select * from rngfuncbar();
column1 | column2
---------+---------
@@ -2302,12 +2302,12 @@ select * from rngfuncbar();
(1 row)
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2) $$ language sql;
+$$ select (1, 2) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
ERROR: function return row and query-specified return row do not match
DETAIL: Returned type integer at ordinal position 2, but query expects numeric.
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1, 3) $$ language sql;
+$$ select (1, 2.1, 3) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
ERROR: function return row and query-specified return row do not match
DETAIL: Returned row contains 3 attributes, but query expects 2.
@@ -2315,7 +2315,7 @@ drop function rngfuncbar();
-- check whole-row-Var handling in nested lateral functions (bug #11703)
create function extractq2(t int8_tbl) returns int8 as $$
select t.q2
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2(int8_tbl) f(x);
QUERY PLAN
@@ -2341,7 +2341,7 @@ select x from int8_tbl, extractq2(int8_tbl) f(x);
create function extractq2_2(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t) offset 0
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2(int8_tbl) f(x);
QUERY PLAN
@@ -2367,7 +2367,7 @@ select x from int8_tbl, extractq2_2(int8_tbl) f(x);
-- without the "offset 0", this function gets optimized quite differently
create function extractq2_2_opt(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t)
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x);
QUERY PLAN
diff --git a/src/test/regress/expected/rangetypes.out b/src/test/regress/expected/rangetypes.out
index 05b882fde9..fa66386ed6 100644
--- a/src/test/regress/expected/rangetypes.out
+++ b/src/test/regress/expected/rangetypes.out
@@ -1539,7 +1539,7 @@ drop type textrange2;
-- Test polymorphic type system
--
create function anyarray_anyrange_func(a anyarray, r anyrange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anyrange_func(ARRAY[1,2], int4range(10,20));
anyarray_anyrange_func
------------------------
@@ -1555,16 +1555,16 @@ HINT: No function matches the given name and argument types. You might need to
drop function anyarray_anyrange_func(anyarray, anyrange);
-- should fail
create function bogus_func(anyelement)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
-- should fail
create function bogus_func(int)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
create function range_add_bounds(anyrange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4range(1, 17));
range_add_bounds
------------------
@@ -1579,7 +1579,7 @@ select range_add_bounds(numrange(1.0001, 123.123));
create function rangetypes_sql(q anyrange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select rangetypes_sql(int4range(1,10), ARRAY[2,20]);
rangetypes_sql
----------------
@@ -1592,7 +1592,7 @@ LINE 1: select rangetypes_sql(numrange(1,10), ARRAY[2,20]);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
create function anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatiblerange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], int4range(10,20));
anycompatiblearray_anycompatiblerange_func
--------------------------------------------
@@ -1614,7 +1614,7 @@ HINT: No function matches the given name and argument types. You might need to
drop function anycompatiblearray_anycompatiblerange_func(anycompatiblearray, anycompatiblerange);
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
--
@@ -1696,7 +1696,7 @@ reset enable_sort;
--
-- infer anyrange from anyrange
create function outparam_succeed(i anyrange, out r anyrange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed(int4range(1,2));
r | t
-------+-----
@@ -1705,7 +1705,7 @@ select * from outparam_succeed(int4range(1,2));
create function outparam2_succeed(r anyrange, out lu anyarray, out ul anyarray)
as $$ select array[lower($1), upper($1)], array[upper($1), lower($1)] $$
- language sql;
+ LANGUAGE SQLTEST;
select * from outparam2_succeed(int4range(1,11));
lu | ul
--------+--------
@@ -1714,7 +1714,7 @@ select * from outparam2_succeed(int4range(1,11));
-- infer anyarray from anyrange
create function outparam_succeed2(i anyrange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed2(int4range(int4range(1,2)));
r | t
-----+-----
@@ -1723,7 +1723,7 @@ select * from outparam_succeed2(int4range(int4range(1,2)));
-- infer anyelement from anyrange
create function inoutparam_succeed(out i anyelement, inout r anyrange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from inoutparam_succeed(int4range(1,2));
i | r
---+-------
@@ -1733,7 +1733,7 @@ select * from inoutparam_succeed(int4range(1,2));
create function table_succeed(r anyrange)
returns table(l anyelement, u anyelement)
as $$ select lower($1), upper($1) $$
- language sql;
+ LANGUAGE SQLTEST;
select * from table_succeed(int4range(1,11));
l | u
---+----
@@ -1742,16 +1742,16 @@ select * from table_succeed(int4range(1,11));
-- should fail
create function outparam_fail(i anyelement, out r anyrange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
--should fail
create function inoutparam_fail(inout i anyelement, out r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
--should fail
create function table_fail(i anyelement) returns table(i anyelement, r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
diff --git a/src/test/regress/expected/rowtypes.out b/src/test/regress/expected/rowtypes.out
index 0e71baf8fb..4b187582b2 100644
--- a/src/test/regress/expected/rowtypes.out
+++ b/src/test/regress/expected/rowtypes.out
@@ -841,10 +841,10 @@ CREATE TYPE price_key AS (
);
CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
insert into price values (1,false,42), (10,false,100), (11,true,17.99);
UPDATE price
SET active = true, price = input_prices.price
@@ -866,20 +866,20 @@ rollback;
create temp table compos (f1 int, f2 text);
create function fcompos1(v compos) returns void as $$
insert into compos values (v); -- fail
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: column "f1" is of type integer but expression is of type compos
LINE 2: insert into compos values (v); -- fail
^
HINT: You will need to rewrite or cast the expression.
create function fcompos1(v compos) returns void as $$
insert into compos values (v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos2(v compos) returns void as $$
select fcompos1(v);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos3(v compos) returns void as $$
select fcompos1(fcompos3.v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select fcompos1(row(1,'one'));
fcompos1
----------
@@ -968,7 +968,7 @@ select last(f) from fullname f;
Blow
(1 row)
-create function longname(fullname) returns text language sql
+create function longname(fullname) returns text LANGUAGE SQLTEST
as $$select $1.first || ' ' || $1.last$$;
select f.longname from fullname f;
longname
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 6173473de9..b55e47b8fc 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -764,7 +764,7 @@ create view rtest_vview4 as select X.a, X.b, count(Y.a) as refcount
group by X.a, X.b;
create function rtest_viewfunc1(int4) returns int4 as
'select count(*)::int4 from rtest_view2 where a = $1'
- language sql;
+ LANGUAGE SQLTEST;
create view rtest_vview5 as select a, b, rtest_viewfunc1(a) as refcount
from rtest_view1;
insert into rtest_view1 values (1, 'item 1', 't');
@@ -1654,7 +1654,7 @@ UNION ALL
l.provider,
l.label
FROM (pg_shseclabel l
- JOIN pg_subscription s ON (((l.classoid = s.tableoid) AND (l.objoid = s.oid))))
+ JOIN pg_sub s ON (((l.classoid = s.tableoid) AND (l.objoid = s.oid))))
UNION ALL
SELECT l.objoid,
l.classoid,
@@ -2064,17 +2064,17 @@ pg_stat_ssl| SELECT s.pid,
s.ssl_issuer_dn AS issuer_dn
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid)
WHERE (s.client_port IS NOT NULL);
-pg_stat_subscription| SELECT su.oid AS subid,
+pg_stat_sub| SELECT su.oid AS subid,
su.subname,
st.pid,
st.relid,
st.received_lsn,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_location,
st.latest_end_time
- FROM (pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL::oid) st(subid, relid, pid, received_lsn, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time) ON ((st.subid = su.oid)));
+ FROM (pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL::oid) st(subid, relid, pid, received_lsn, last_msg_send_time, last_msg_receipt_time, latest_end_location, latest_end_time) ON ((st.subid = su.oid)));
pg_stat_sys_indexes| SELECT pg_stat_all_indexes.relid,
pg_stat_all_indexes.indexrelid,
pg_stat_all_indexes.schemaname,
@@ -2169,13 +2169,13 @@ pg_stat_wal_receiver| SELECT s.pid,
s.received_tli,
s.last_msg_send_time,
s.last_msg_receipt_time,
- s.latest_end_lsn,
+ s.latest_end_location,
s.latest_end_time,
s.slot_name,
s.sender_host,
s.sender_port,
s.conninfo
- FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time, slot_name, sender_host, sender_port, conninfo)
+ FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_location, latest_end_time, slot_name, sender_host, sender_port, conninfo)
WHERE (s.pid IS NOT NULL);
pg_stat_xact_all_tables| SELECT c.oid AS relid,
n.nspname AS schemaname,
@@ -3424,7 +3424,7 @@ drop table hat_data;
-- Note that the function is kept around to stress pg_dump.
CREATE FUNCTION func_with_set_params() RETURNS integer
AS 'select 1;'
- LANGUAGE SQL
+ LANGUAGE SQLTEST
SET search_path TO PG_CATALOG
SET extra_float_digits TO 2
SET work_mem TO '4MB'
@@ -3436,7 +3436,7 @@ SELECT pg_get_functiondef('func_with_set_params()'::regprocedure);
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION public.func_with_set_params() +
RETURNS integer +
- LANGUAGE sql +
+ LANGUAGE sqltest +
IMMUTABLE STRICT +
SET search_path TO 'pg_catalog' +
SET extra_float_digits TO '2' +
diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out
index d9ce961be2..a1c612b5bd 100644
--- a/src/test/regress/expected/sanity_check.out
+++ b/src/test/regress/expected/sanity_check.out
@@ -151,8 +151,8 @@ pg_shseclabel|t
pg_statistic|t
pg_statistic_ext|t
pg_statistic_ext_data|t
-pg_subscription|t
-pg_subscription_rel|t
+pg_sub|t
+pg_sub_rel|t
pg_tablespace|t
pg_transform|t
pg_trigger|t
diff --git a/src/test/regress/expected/select.out b/src/test/regress/expected/select.out
index c441049f41..494911ffb6 100644
--- a/src/test/regress/expected/select.out
+++ b/src/test/regress/expected/select.out
@@ -915,7 +915,7 @@ SELECT 1 AS x ORDER BY x;
-- But ORDER BY on a set-valued expression does
create function sillysrf(int) returns setof int as
- 'values (1),(10),(2),($1)' language sql immutable;
+ 'values (1),(10),(2),($1)' LANGUAGE SQLTEST immutable;
select sillysrf(42);
sillysrf
----------
diff --git a/src/test/regress/expected/select_into.out b/src/test/regress/expected/select_into.out
index 43b8209d22..34e9503367 100644
--- a/src/test/regress/expected/select_into.out
+++ b/src/test/regress/expected/select_into.out
@@ -133,7 +133,7 @@ DROP TABLE ctas_nodata_4;
CREATE FUNCTION make_table() RETURNS VOID
AS $$
CREATE TABLE created_table AS SELECT * FROM int8_tbl;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
SELECT make_table();
make_table
------------
diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out
index 9b0c418db7..cf56b27664 100644
--- a/src/test/regress/expected/select_parallel.out
+++ b/src/test/regress/expected/select_parallel.out
@@ -124,7 +124,7 @@ reset enable_parallel_append;
-- Parallel Append that runs serially
create function sp_test_func() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select sp_test_func() order by 1;
sp_test_func
--------------
diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out
index 2fa9bce66a..54ab1efd06 100644
--- a/src/test/regress/expected/subscription.out
+++ b/src/test/regress/expected/subscription.out
@@ -31,7 +31,7 @@ ERROR: publication name "foo" used more than once
CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false);
WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables
COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription';
-SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
+SELECT obj_description(s.oid, 'pg_sub') FROM pg_sub s;
obj_description
-------------------
test subscription
diff --git a/src/test/regress/expected/subselect.out b/src/test/regress/expected/subselect.out
index d5532d0ccc..ec73a50e30 100644
--- a/src/test/regress/expected/subselect.out
+++ b/src/test/regress/expected/subselect.out
@@ -811,7 +811,7 @@ HINT: No operator matches the given name and argument types. You might need to
begin;
-- make an operator to allow it to succeed
create function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2';
create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text);
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
@@ -833,7 +833,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function results in unusual number of hash clauses,
-- which we can still cope with
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2 and $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2 and $1::text = $2';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
QUERY PLAN
@@ -854,7 +854,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function causes LHS and RHS to be switched,
-- which we can't cope with, so hashing should be abandoned
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $2 = $1::text';
+LANGUAGE SQLTEST as 'select $2 = $1::text';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
QUERY PLAN
diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/temp.out
index a5b3ed34a3..1033b844c6 100644
--- a/src/test/regress/expected/temp.out
+++ b/src/test/regress/expected/temp.out
@@ -149,9 +149,9 @@ insert into public.whereami values ('public');
create temp table whereami (f1 text);
insert into whereami values ('temp');
create function public.whoami() returns text
- as $$select 'public'::text$$ language sql;
+ as $$select 'public'::text$$ LANGUAGE SQLTEST;
create function pg_temp.whoami() returns text
- as $$select 'temp'::text$$ language sql;
+ as $$select 'temp'::text$$ LANGUAGE SQLTEST;
-- default should have pg_temp implicitly first, but only for tables
select * from whereami;
f1
@@ -326,12 +326,12 @@ drop table temp_inh_oncommit_test;
-- Function creation
begin;
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
prepare transaction 'twophase_func';
ERROR: cannot PREPARE a transaction that has operated on temporary objects
-- Function drop
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
begin;
drop function pg_temp.twophase_func();
prepare transaction 'twophase_func';
diff --git a/src/test/regress/expected/transactions.out b/src/test/regress/expected/transactions.out
index 1b03310029..68153b45d3 100644
--- a/src/test/regress/expected/transactions.out
+++ b/src/test/regress/expected/transactions.out
@@ -472,7 +472,7 @@ select * from xacttest;
777 | 777.777
(5 rows)
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' stable;
begin;
update xacttest set a = max_xacttest() + 10 where a > 0;
@@ -488,7 +488,7 @@ select * from xacttest;
rollback;
-- But a volatile function can see the partial results of the calling query
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' volatile;
begin;
update xacttest set a = max_xacttest() + 10 where a > 0;
diff --git a/src/test/regress/expected/typed_table.out b/src/test/regress/expected/typed_table.out
index 2e47ecbcf5..d70baad15d 100644
--- a/src/test/regress/expected/typed_table.out
+++ b/src/test/regress/expected/typed_table.out
@@ -18,7 +18,7 @@ SELECT * FROM persons;
Typed table of type: person_type
CREATE FUNCTION get_all_persons() RETURNS SETOF person_type
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT * FROM persons;
$$;
@@ -95,7 +95,7 @@ DROP TABLE stuff;
CREATE TYPE person_type AS (id int, name text);
CREATE TABLE persons OF person_type;
INSERT INTO persons VALUES (1, 'test');
-CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$;
+CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQLTEST AS $$ SELECT length($1.name) $$;
SELECT id, namelen(persons) FROM persons;
id | namelen
----+---------
diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out
index 24905332b1..0380b393b7 100644
--- a/src/test/regress/expected/updatable_views.out
+++ b/src/test/regress/expected/updatable_views.out
@@ -944,7 +944,7 @@ CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified');
INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i);
CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl;
CREATE FUNCTION rw_view1_aa(x rw_view1)
- RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql;
+ RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sqltest;
UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2
RETURNING rw_view1_aa(v), v.bb;
rw_view1_aa | bb
diff --git a/src/test/regress/expected/vacuum.out b/src/test/regress/expected/vacuum.out
index 3fccb183c0..98f36f3a2c 100644
--- a/src/test/regress/expected/vacuum.out
+++ b/src/test/regress/expected/vacuum.out
@@ -61,9 +61,9 @@ VACUUM (ANALYZE, FULL) vactst;
CREATE TABLE vaccluster (i INT PRIMARY KEY);
ALTER TABLE vaccluster CLUSTER ON vaccluster_pkey;
CLUSTER vaccluster;
-CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL
+CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQLTEST
AS 'ANALYZE pg_am';
-CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL
+CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQLTEST
AS 'SELECT $1 FROM do_analyze()';
CREATE INDEX ON vaccluster(wrap_do_analyze(i));
INSERT INTO vaccluster VALUES (1), (2);
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out
index 19e2ac518a..c3a344c780 100644
--- a/src/test/regress/expected/window.out
+++ b/src/test/regress/expected/window.out
@@ -3318,13 +3318,13 @@ SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four
-- intentionally not true inverses)
CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE AGGREGATE logging_agg_nonstrict (anyelement)
(
stype = text,
@@ -3345,13 +3345,13 @@ CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement)
);
CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '*' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '+' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE AGGREGATE logging_agg_strict (text)
(
stype = text,
@@ -3501,7 +3501,7 @@ ORDER BY i;
-- that one aggregate restarting doesn't cause others to restart.
CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS
$$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$
-LANGUAGE SQL STRICT;
+LANGUAGE SQLTEST STRICT;
CREATE AGGREGATE sum_int_randomrestart (int4)
(
stype = int4,
@@ -4042,7 +4042,7 @@ AS $$
SELECT array_agg(s) OVER w
FROM generate_series(1,5) s
WINDOW w AS (ORDER BY s ROWS BETWEEN CURRENT ROW AND GROUP_SIZE FOLLOWING)
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQLTEST STABLE;
EXPLAIN (costs off) SELECT * FROM pg_temp.f(2);
QUERY PLAN
------------------------------------------------------
diff --git a/src/test/regress/input/create_function_1.source b/src/test/regress/input/create_function_1.source
index 412e339fcf..c83845b8fe 100644
--- a/src/test/regress/input/create_function_1.source
+++ b/src/test/regress/input/create_function_1.source
@@ -80,19 +80,19 @@ CREATE FUNCTION test_opclass_options_func(internal)
-- Things that shouldn't work:
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT ''not an integer'';';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'not even SQL';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT 1, 2, 3;';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT $2;';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'a', 'b';
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
diff --git a/src/test/regress/input/create_function_2.source b/src/test/regress/input/create_function_2.source
index 9e6d2942ec..2af7dcaaf7 100644
--- a/src/test/regress/input/create_function_2.source
+++ b/src/test/regress/input/create_function_2.source
@@ -4,62 +4,62 @@
CREATE FUNCTION hobbies(person)
RETURNS setof hobbies_r
AS 'select * from hobbies_r where person = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct(text, text)
RETURNS hobbies_r
AS 'select $1 as name, $2 as hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct_named(name text, hobby text)
RETURNS hobbies_r
AS 'select name, hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE)
RETURNS hobbies_r.person%TYPE
AS 'select person from hobbies_r where name = $1'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment(hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = equipment_named.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1a(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_1a.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1b(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1c(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2a(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_2a.hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2b(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION pt_in_widget(point, widget)
diff --git a/src/test/regress/output/create_function_1.source b/src/test/regress/output/create_function_1.source
index 4d78fa1228..5d3a606f47 100644
--- a/src/test/regress/output/create_function_1.source
+++ b/src/test/regress/output/create_function_1.source
@@ -69,27 +69,27 @@ CREATE FUNCTION test_opclass_options_func(internal)
AS '@libdir@/regress@DLSUFFIX@', 'test_opclass_options_func'
LANGUAGE C;
-- Things that shouldn't work:
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT ''not an integer'';';
ERROR: return type mismatch in function declared to return integer
DETAIL: Actual return type is text.
CONTEXT: SQL function "test1"
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'not even SQL';
ERROR: syntax error at or near "not"
LINE 2: AS 'not even SQL';
^
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT 1, 2, 3;';
ERROR: return type mismatch in function declared to return integer
DETAIL: Final statement must return exactly one column.
CONTEXT: SQL function "test1"
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT $2;';
ERROR: there is no parameter $2
LINE 2: AS 'SELECT $2;';
^
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'a', 'b';
ERROR: only one AS item needed for language "sql"
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
diff --git a/src/test/regress/output/create_function_2.source b/src/test/regress/output/create_function_2.source
index ac9a7f5cf8..d98de86161 100644
--- a/src/test/regress/output/create_function_2.source
+++ b/src/test/regress/output/create_function_2.source
@@ -4,49 +4,49 @@
CREATE FUNCTION hobbies(person)
RETURNS setof hobbies_r
AS 'select * from hobbies_r where person = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct(text, text)
RETURNS hobbies_r
AS 'select $1 as name, $2 as hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct_named(name text, hobby text)
RETURNS hobbies_r
AS 'select name, hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE)
RETURNS hobbies_r.person%TYPE
AS 'select person from hobbies_r where name = $1'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
NOTICE: type reference hobbies_r.name%TYPE converted to text
NOTICE: type reference hobbies_r.person%TYPE converted to text
CREATE FUNCTION equipment(hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = equipment_named.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1a(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_1a.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1b(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1c(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2a(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_2a.hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2b(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION pt_in_widget(point, widget)
RETURNS bool
AS '@libdir@/regress@DLSUFFIX@'
diff --git a/src/test/regress/sql/alter_generic.sql b/src/test/regress/sql/alter_generic.sql
index 8c5d0e5e1f..75fa8f6b6e 100644
--- a/src/test/regress/sql/alter_generic.sql
+++ b/src/test/regress/sql/alter_generic.sql
@@ -26,9 +26,9 @@ SET search_path = alt_nsp1, public;
-- Function and Aggregate
--
SET SESSION AUTHORIZATION regress_alter_generic_user1;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 1';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 1';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0
@@ -54,9 +54,9 @@ ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3; -- OK
ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2; -- OK
SET SESSION AUTHORIZATION regress_alter_generic_user2;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 2';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 2';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100
@@ -354,7 +354,7 @@ DROP OPERATOR FAMILY alt_opf11 USING gist;
-- Should fail. btree comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf12 USING btree;
-CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2);
DROP OPERATOR FAMILY alt_opf12 USING btree;
ROLLBACK;
@@ -362,7 +362,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf13 USING hash;
-CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4);
DROP OPERATOR FAMILY alt_opf13 USING hash;
ROLLBACK;
@@ -370,7 +370,7 @@ ROLLBACK;
-- Should fail. btree comparison functions should have two arguments in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf14 USING btree;
-CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4);
DROP OPERATOR FAMILY alt_opf14 USING btree;
ROLLBACK;
@@ -378,7 +378,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should have one argument in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf15 USING hash;
-CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2);
DROP OPERATOR FAMILY alt_opf15 USING hash;
ROLLBACK;
diff --git a/src/test/regress/sql/alter_operator.sql b/src/test/regress/sql/alter_operator.sql
index fd40370165..91f4a2c187 100644
--- a/src/test/regress/sql/alter_operator.sql
+++ b/src/test/regress/sql/alter_operator.sql
@@ -1,5 +1,5 @@
CREATE FUNCTION alter_op_test_fn(boolean, boolean)
-RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
+RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sqltest IMMUTABLE;
CREATE FUNCTION customcontsel(internal, oid, internal, integer)
RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT;
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 4cc55d8525..4e5af2014c 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -1798,14 +1798,14 @@ drop type lockmodes;
--
create function test_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql returns null on null input;
+ LANGUAGE SQLTEST returns null on null input;
select test_strict(NULL);
alter function test_strict(text) called on null input;
select test_strict(NULL);
create function non_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql called on null input;
+ LANGUAGE SQLTEST called on null input;
select non_strict(NULL);
alter function non_strict(text) returns null on null input;
select non_strict(NULL);
@@ -1821,13 +1821,13 @@ create table alter1.t1(f1 serial primary key, f2 int check (f2 > 0));
create view alter1.v1 as select * from alter1.t1;
-create function alter1.plus1(int) returns int as 'select $1+1' language sql;
+create function alter1.plus1(int) returns int as 'select $1+1' LANGUAGE SQLTEST;
create domain alter1.posint integer check (value > 0);
create type alter1.ctype as (f1 int, f2 text);
-create function alter1.same(alter1.ctype, alter1.ctype) returns boolean language sql
+create function alter1.same(alter1.ctype, alter1.ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
create operator alter1.=(procedure = alter1.same, leftarg = alter1.ctype, rightarg = alter1.ctype);
@@ -2838,7 +2838,7 @@ drop function func_part_attach();
-- test case where the partitioning operator is a SQL function whose
-- evaluation results in the table's relcache being rebuilt partway through
-- the execution of an ATTACH PARTITION command
-create function at_test_sql_partop (int4, int4) returns int language sql
+create function at_test_sql_partop (int4, int4) returns int LANGUAGE SQLTEST
as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$;
create operator class at_test_sql_partop for type int4 using btree as
operator 1 < (int4, int4), operator 2 <= (int4, int4),
diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql
index c40619a8d5..ca9cfd41da 100644
--- a/src/test/regress/sql/arrays.sql
+++ b/src/test/regress/sql/arrays.sql
@@ -499,13 +499,13 @@ drop type comptype;
create or replace function unnest1(anyarray)
returns setof anyelement as $$
select $1[s] from generate_subscripts($1,1) g(s);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create or replace function unnest2(anyarray)
returns setof anyelement as $$
select $1[s1][s2] from generate_subscripts($1,1) g1(s1),
generate_subscripts($1,2) g2(s2);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select * from unnest1(array[1,2,3]);
select * from unnest2(array[[1,2,3],[4,5,6]]);
diff --git a/src/test/regress/sql/case.sql b/src/test/regress/sql/case.sql
index 0655d266f6..dce020ea2f 100644
--- a/src/test/regress/sql/case.sql
+++ b/src/test/regress/sql/case.sql
@@ -196,7 +196,7 @@ CREATE FUNCTION volfoo(text) returns foodomain as
'begin return $1::foodomain; end' language plpgsql volatile;
CREATE FUNCTION inline_eq(foodomain, foodomain) returns boolean as
- 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' language sql;
+ 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' LANGUAGE SQLTEST;
CREATE OPERATOR = (procedure = inline_eq,
leftarg = foodomain, rightarg = foodomain);
diff --git a/src/test/regress/sql/collate.icu.utf8.sql b/src/test/regress/sql/collate.icu.utf8.sql
index 0de2ed8d85..d4d3a6d8be 100644
--- a/src/test/regress/sql/collate.icu.utf8.sql
+++ b/src/test/regress/sql/collate.icu.utf8.sql
@@ -266,10 +266,10 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
@@ -322,7 +322,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER
SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1;
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
diff --git a/src/test/regress/sql/collate.linux.utf8.sql b/src/test/regress/sql/collate.linux.utf8.sql
index c697c99488..6767fc9379 100644
--- a/src/test/regress/sql/collate.linux.utf8.sql
+++ b/src/test/regress/sql/collate.linux.utf8.sql
@@ -274,10 +274,10 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
@@ -330,7 +330,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER
SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1;
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
diff --git a/src/test/regress/sql/collate.sql b/src/test/regress/sql/collate.sql
index 82f9c855b8..f518856165 100644
--- a/src/test/regress/sql/collate.sql
+++ b/src/test/regress/sql/collate.sql
@@ -179,7 +179,7 @@ SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2;
-- result of a SQL function
-CREATE FUNCTION vc (text) RETURNS text LANGUAGE sql
+CREATE FUNCTION vc (text) RETURNS text LANGUAGE sqltest
AS 'select $1::varchar';
SELECT a, b FROM collate_test1 ORDER BY a, vc(b);
@@ -191,7 +191,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER
SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1;
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
diff --git a/src/test/regress/sql/create_aggregate.sql b/src/test/regress/sql/create_aggregate.sql
index d4b4036fd7..69b1b97511 100644
--- a/src/test/regress/sql/create_aggregate.sql
+++ b/src/test/regress/sql/create_aggregate.sql
@@ -44,7 +44,7 @@ COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment';
-- multi-argument aggregate
create function sum3(int8,int8,int8) returns int8 as
-'select $1 + $2 + $3' language sql strict immutable;
+'select $1 + $2 + $3' LANGUAGE SQLTEST strict immutable;
create aggregate sum2(int8,int8) (
sfunc = sum3, stype = int8,
@@ -56,11 +56,11 @@ create type aggtype as (a integer, b integer, c text);
create function aggf_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql strict immutable;
+LANGUAGE SQLTEST strict immutable;
create function aggfns_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql immutable;
+LANGUAGE SQLTEST immutable;
create aggregate aggfstr(integer,integer,text) (
sfunc = aggf_trans, stype = aggtype[],
@@ -73,7 +73,7 @@ create aggregate aggfns(integer,integer,text) (
);
-- check error cases that would require run-time type coercion
-create function least_accum(int8, int8) returns int8 language sql as
+create function least_accum(int8, int8) returns int8 LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
@@ -83,7 +83,7 @@ create aggregate least_agg(int4) (
drop function least_accum(int8, int8);
create function least_accum(anycompatible, anycompatible)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
@@ -98,7 +98,7 @@ drop function least_accum(anycompatible, anycompatible) cascade;
-- variadic aggregates
create function least_accum(anyelement, variadic anyarray)
-returns anyelement language sql as
+returns anyelement LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate least_agg(variadic items anyarray) (
@@ -106,7 +106,7 @@ create aggregate least_agg(variadic items anyarray) (
);
create function cleast_accum(anycompatible, variadic anycompatiblearray)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate cleast_agg(variadic items anycompatiblearray) (
@@ -259,7 +259,7 @@ CREATE OR REPLACE AGGREGATE myavg (order by numeric)
-- can't change plain function to aggregate:
create function sum4(int8,int8,int8,int8) returns int8 as
-'select $1 + $2 + $3 + $4' language sql strict immutable;
+'select $1 + $2 + $3 + $4' LANGUAGE SQLTEST strict immutable;
CREATE OR REPLACE AGGREGATE sum3 (int8,int8,int8)
(
@@ -283,7 +283,7 @@ CREATE AGGREGATE mysum (int)
CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS
$$ SELECT $1 - $2; $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE invalidsumdouble (float8)
(
@@ -298,7 +298,7 @@ CREATE AGGREGATE invalidsumdouble (float8)
CREATE FUNCTION float8mi_int(float8, float8) RETURNS int AS
$$ SELECT CAST($1 - $2 AS INT); $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE wrongreturntype (float8)
(
diff --git a/src/test/regress/sql/create_cast.sql b/src/test/regress/sql/create_cast.sql
index b11cf88b06..219edd67fc 100644
--- a/src/test/regress/sql/create_cast.sql
+++ b/src/test/regress/sql/create_cast.sql
@@ -22,7 +22,7 @@ CREATE TYPE casttesttype (
);
-- a dummy function to test with
-CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQL AS
+CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQLTEST AS
$$ SELECT 1; $$;
SELECT casttestfunc('foo'::text); -- fails, as there's no cast
@@ -47,7 +47,7 @@ DROP CAST (int4 AS casttesttype);
-- Try cast with a function
-CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQL AS
+CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQLTEST AS
$$ SELECT ('foo'::text || $1::text)::casttesttype; $$;
CREATE CAST (int4 AS casttesttype) WITH FUNCTION int4_casttesttype(int4) AS IMPLICIT;
diff --git a/src/test/regress/sql/create_function_3.sql b/src/test/regress/sql/create_function_3.sql
index bd108a918f..c404f38f7d 100644
--- a/src/test/regress/sql/create_function_3.sql
+++ b/src/test/regress/sql/create_function_3.sql
@@ -20,11 +20,11 @@ SET search_path TO temp_func_test, public;
--
-- ARGUMENT and RETURN TYPES
--
-CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
-CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
+CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sqltest'
AS 'SELECT $1[1]::int';
-CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT false';
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
WHERE oid in ('functest_A_1'::regproc,
@@ -38,13 +38,13 @@ SELECT functest_A_3();
--
-- IMMUTABLE | STABLE | VOLATILE
--
-CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sqltest'
STABLE AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sqltest'
VOLATILE AS 'SELECT $1 < 0';
SELECT proname, provolatile FROM pg_proc
WHERE oid in ('functest_B_1'::regproc,
@@ -63,11 +63,11 @@ SELECT proname, provolatile FROM pg_proc
--
-- SECURITY DEFINER | INVOKER
--
-CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY DEFINER AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY INVOKER AS 'SELECT $1 < 0';
SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functest_C_1'::regproc,
@@ -85,9 +85,9 @@ SELECT proname, prosecdef FROM pg_proc
--
-- LEAKPROOF
--
-CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 100';
-CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 > 100';
SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functest_E_1'::regproc,
@@ -113,7 +113,7 @@ SET search_path TO temp_func_test, public;
ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF;
ALTER FUNCTION functest_E_2(int) LEAKPROOF;
-CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 < 200'; -- fail
RESET SESSION AUTHORIZATION;
@@ -121,13 +121,13 @@ RESET SESSION AUTHORIZATION;
--
-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
--
-CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 50';
-CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sqltest'
CALLED ON NULL INPUT AS 'SELECT $1 = 50';
-CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sqltest'
RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50';
-CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sqltest'
STRICT AS 'SELECT $1 = 50';
SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functest_F_1'::regproc,
@@ -157,17 +157,17 @@ SELECT pg_get_functiondef('functest_F_2'::regproc);
CREATE FUNCTION functest_IS_1(a int, b int default 1, c text default 'foo')
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1 + $2';
CREATE FUNCTION functest_IS_2(out a int, b int default 1)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
CREATE FUNCTION functest_IS_3(a int default 1, out b int)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
SELECT routine_name, ordinal_position, parameter_name, parameter_default
@@ -178,7 +178,7 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
-- overload
-CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
DROP FUNCTION functest_b_1;
@@ -188,19 +188,19 @@ DROP FUNCTION functest_b_2; -- error, ambiguous
-- CREATE OR REPLACE tests
-CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL AS 'SELECT $1';
-CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL WINDOW AS 'SELECT $1';
-CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQL AS 'SELECT $1';
+CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST AS 'SELECT $1';
+CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST WINDOW AS 'SELECT $1';
+CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQLTEST AS 'SELECT $1';
DROP FUNCTION functest1(a int);
-- Check behavior of VOID-returning SQL functions
-CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT a + 1 $$;
SELECT voidtest1(42);
-CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT voidtest1(a + b) $$;
SELECT voidtest2(11,22);
@@ -209,17 +209,17 @@ EXPLAIN (verbose, costs off) SELECT voidtest2(11,22);
CREATE TEMP TABLE sometable(f1 int);
-CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a + 1) $$;
SELECT voidtest3(17);
-CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a - 1) RETURNING f1 $$;
SELECT voidtest4(39);
TABLE sometable;
-CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQLTEST AS
$$ SELECT generate_series(1, a) $$ STABLE;
SELECT * FROM voidtest5(3);
diff --git a/src/test/regress/sql/create_operator.sql b/src/test/regress/sql/create_operator.sql
index 4ff2c0ff21..ebf1eddab7 100644
--- a/src/test/regress/sql/create_operator.sql
+++ b/src/test/regress/sql/create_operator.sql
@@ -117,7 +117,7 @@ BEGIN TRANSACTION;
CREATE OR REPLACE FUNCTION fn_op2(boolean, boolean)
RETURNS boolean AS $$
SELECT NULL::BOOLEAN;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
CREATE OPERATOR === (
LEFTARG = boolean,
RIGHTARG = boolean,
@@ -154,7 +154,7 @@ CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op3(type_op3, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op3 FROM regress_rol_op3;
REVOKE USAGE ON TYPE type_op3 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op3;
@@ -172,7 +172,7 @@ CREATE TYPE type_op4 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op4(int8, type_op4)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op4 FROM regress_rol_op4;
REVOKE USAGE ON TYPE type_op4 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op4;
@@ -190,7 +190,7 @@ CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op5(int8, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM PUBLIC;-- Need to do this so that regress_rol_op3 is not allowed EXECUTE via PUBLIC
SET ROLE regress_rol_op5;
@@ -208,7 +208,7 @@ CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op6(int8, int8)
RETURNS type_op6 AS $$
SELECT NULL::type_op6;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op6 FROM regress_rol_op6;
REVOKE USAGE ON TYPE type_op6 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op6;
diff --git a/src/test/regress/sql/create_procedure.sql b/src/test/regress/sql/create_procedure.sql
index 2ef1c82cea..110ce78891 100644
--- a/src/test/regress/sql/create_procedure.sql
+++ b/src/test/regress/sql/create_procedure.sql
@@ -1,12 +1,12 @@
CALL nonexistent(); -- error
CALL random(); -- error
-CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQL AS $$ SELECT a $$;
+CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQLTEST AS $$ SELECT a $$;
CREATE TABLE cp_test (a int, b text);
CREATE PROCEDURE ptest1(x text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, x);
$$;
@@ -29,7 +29,7 @@ SELECT * FROM cp_test ORDER BY b COLLATE "C";
CREATE PROCEDURE ptest2()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 5;
$$;
@@ -41,7 +41,7 @@ CALL ptest2();
TRUNCATE cp_test;
CREATE PROCEDURE ptest3(y text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest1(y);
CALL ptest1($1);
@@ -55,7 +55,7 @@ SELECT * FROM cp_test;
-- output arguments
CREATE PROCEDURE ptest4a(INOUT a int, INOUT b int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 1, 2;
$$;
@@ -63,7 +63,7 @@ $$;
CALL ptest4a(NULL, NULL);
CREATE PROCEDURE ptest4b(INOUT b int, INOUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest4a(a, b); -- error, not supported
$$;
@@ -74,7 +74,7 @@ DROP PROCEDURE ptest4a;
-- named and default parameters
CREATE OR REPLACE PROCEDURE ptest5(a int, b text, c int default 100)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES(a, b);
INSERT INTO cp_test VALUES(c, b);
@@ -93,7 +93,7 @@ SELECT * FROM cp_test;
-- polymorphic types
CREATE PROCEDURE ptest6(a int, b anyelement)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT NULL::int;
$$;
@@ -104,7 +104,7 @@ CALL ptest6(1, 2);
-- collation assignment
CREATE PROCEDURE ptest7(a text, b text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT a = b;
$$;
@@ -115,7 +115,7 @@ CALL ptest7(least('a', 'b'), 'a');
-- OUT parameters
CREATE PROCEDURE ptest9(OUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, 'a');
SELECT 1;
@@ -129,8 +129,8 @@ CALL ptest9(NULL);
CALL version(); -- error: not a procedure
CALL sum(1); -- error: not a procedure
-CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
-CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
ALTER PROCEDURE ptest1(text) STRICT;
ALTER FUNCTION ptest1(text) VOLATILE; -- error: not a function
diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql
index d257679ba6..048d10a50e 100644
--- a/src/test/regress/sql/create_table.sql
+++ b/src/test/regress/sql/create_table.sql
@@ -355,7 +355,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a);
-- prevent using prohibited expressions in the key
-CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (retset(a));
@@ -378,7 +378,7 @@ CREATE TABLE partitioned (
a int
) PARTITION BY RANGE ((42));
-CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (const_func());
@@ -410,7 +410,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a, ('unknown'));
-- functions in key must be immutable
-CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL;
+CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (immut_func(a));
@@ -437,7 +437,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a);
-- some checks after successful creation of a partitioned table
-CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL;
+CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int,
@@ -866,7 +866,7 @@ CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, M
DROP TABLE range_parted4;
-- user-defined operator class in partition key
-CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql
+CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sqltest
AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$;
CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS
OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4),
diff --git a/src/test/regress/sql/create_type.sql b/src/test/regress/sql/create_type.sql
index a32a9e6795..e0eda962b7 100644
--- a/src/test/regress/sql/create_type.sql
+++ b/src/test/regress/sql/create_type.sql
@@ -117,7 +117,7 @@ CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42);
CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS '
SELECT * FROM default_test;
-' LANGUAGE SQL;
+' LANGUAGE SQLTEST;
SELECT * FROM get_default_test();
diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql
index 549c0b5adf..bd0438dc3e 100644
--- a/src/test/regress/sql/domain.sql
+++ b/src/test/regress/sql/domain.sql
@@ -724,7 +724,7 @@ drop domain di;
--
create function sql_is_distinct_from(anyelement, anyelement)
-returns boolean language sql
+returns boolean LANGUAGE SQLTEST
as 'select $1 is distinct from $2 limit 1';
create domain inotnull int
diff --git a/src/test/regress/sql/drop_if_exists.sql b/src/test/regress/sql/drop_if_exists.sql
index ac6168b91f..020d32d00f 100644
--- a/src/test/regress/sql/drop_if_exists.sql
+++ b/src/test/regress/sql/drop_if_exists.sql
@@ -274,8 +274,8 @@ DROP VIEW IF EXISTS no_such_schema.foo;
-- Check we receive an ambiguous function error when there are
-- multiple matching functions.
-CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ language sql;
-CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ language sql;
+CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ LANGUAGE SQLTEST;
+CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ LANGUAGE SQLTEST;
DROP FUNCTION test_ambiguous_funcname;
DROP FUNCTION IF EXISTS test_ambiguous_funcname;
diff --git a/src/test/regress/sql/event_trigger.sql b/src/test/regress/sql/event_trigger.sql
index 18b2a267cb..ae028331c1 100644
--- a/src/test/regress/sql/event_trigger.sql
+++ b/src/test/regress/sql/event_trigger.sql
@@ -19,7 +19,7 @@ returns event_trigger as $$ BEGIN RETURN 1; END $$ language plpgsql;
-- should fail, SQL functions cannot be event triggers
create function test_event_trigger_sql() returns event_trigger as $$
-SELECT 1 $$ language sql;
+SELECT 1 $$ LANGUAGE SQLTEST;
-- should fail, no elephant_bootstrap entry point
create event trigger regress_event_trigger on elephant_bootstrap
diff --git a/src/test/regress/sql/foreign_data.sql b/src/test/regress/sql/foreign_data.sql
index 73f9f621d8..437bd1be27 100644
--- a/src/test/regress/sql/foreign_data.sql
+++ b/src/test/regress/sql/foreign_data.sql
@@ -52,7 +52,7 @@ CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator;
\dew+
-- HANDLER related checks
-CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;';
+CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQLTEST AS 'SELECT 1;';
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler; -- ERROR
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler;
diff --git a/src/test/regress/sql/generated.sql b/src/test/regress/sql/generated.sql
index bd2b0bfaaa..49fa1da9c7 100644
--- a/src/test/regress/sql/generated.sql
+++ b/src/test/regress/sql/generated.sql
@@ -226,7 +226,7 @@ CREATE TABLE gtest11s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (b *
INSERT INTO gtest11s VALUES (1, 10), (2, 20);
GRANT SELECT (a, c) ON gtest11s TO regress_user11;
-CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQL;
+CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQLTEST;
REVOKE ALL ON FUNCTION gf1(int) FROM PUBLIC;
CREATE TABLE gtest12s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (gf1(b)) STORED);
diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql
index 43dbba3775..ec986f226c 100644
--- a/src/test/regress/sql/guc.sql
+++ b/src/test/regress/sql/guc.sql
@@ -205,7 +205,7 @@ reset search_path;
set work_mem = '3MB';
create function report_guc(text) returns text as
-$$ select current_setting($1) $$ language sql
+$$ select current_setting($1) $$ LANGUAGE SQLTEST
set work_mem = '1MB';
select report_guc('work_mem'), current_setting('work_mem');
@@ -280,13 +280,13 @@ select current_setting('nosuch.setting', true);
-- because that creates ordering hazards for pg_dump
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
set check_function_bodies = off;
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
select func_with_bad_set();
diff --git a/src/test/regress/sql/infinite_recurse.sql b/src/test/regress/sql/infinite_recurse.sql
index 151dba4a7a..c3f4f3ae6d 100644
--- a/src/test/regress/sql/infinite_recurse.sql
+++ b/src/test/regress/sql/infinite_recurse.sql
@@ -2,7 +2,7 @@
-- max_stack_depth is not set too high.
create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
+'select infinite_recurse()' LANGUAGE SQLTEST;
-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
-- signal handling that would cause this test to crash if it happened
diff --git a/src/test/regress/sql/inherit.sql b/src/test/regress/sql/inherit.sql
index 64173a8738..fe1cb7775c 100644
--- a/src/test/regress/sql/inherit.sql
+++ b/src/test/regress/sql/inherit.sql
@@ -251,7 +251,7 @@ drop table base;
create table p1(ff1 int);
create table p2(f1 text);
-create function p2text(p2) returns text as 'select $1.f1' language sql;
+create function p2text(p2) returns text as 'select $1.f1' LANGUAGE SQLTEST;
create table c1(f3 int) inherits(p1,p2);
insert into c1 values(123456789, 'hi', 42);
select p2text(c1.*) from c1;
diff --git a/src/test/regress/sql/insert.sql b/src/test/regress/sql/insert.sql
index 963faa1614..06cad2c9f5 100644
--- a/src/test/regress/sql/insert.sql
+++ b/src/test/regress/sql/insert.sql
@@ -236,7 +236,7 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
create or replace function part_hashint4_noop(value int4, seed int8)
returns int8 as $$
select value + seed;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_int4_ops
for type int4
@@ -247,7 +247,7 @@ function 2 part_hashint4_noop(int4, int8);
create or replace function part_hashtext_length(value text, seed int8)
RETURNS int8 AS $$
select length(coalesce(value, ''))::int8
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_text_ops
for type text
diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql
index 9887fe0c0b..555302e841 100644
--- a/src/test/regress/sql/join.sql
+++ b/src/test/regress/sql/join.sql
@@ -1135,10 +1135,10 @@ drop function f_immutable_int4(int);
-- test inlining when function returns composite
create function mki8(bigint, bigint) returns int8_tbl as
-$$select row($1,$2)::int8_tbl$$ language sql;
+$$select row($1,$2)::int8_tbl$$ LANGUAGE SQLTEST;
create function mki4(int) returns int4_tbl as
-$$select row($1)::int4_tbl$$ language sql;
+$$select row($1)::int4_tbl$$ LANGUAGE SQLTEST;
explain (verbose, costs off)
select * from mki8(1,2);
diff --git a/src/test/regress/sql/multirangetypes.sql b/src/test/regress/sql/multirangetypes.sql
index 692f2416d9..176812969d 100644
--- a/src/test/regress/sql/multirangetypes.sql
+++ b/src/test/regress/sql/multirangetypes.sql
@@ -630,7 +630,7 @@ drop type textrange2;
--
create function anyarray_anymultirange_func(a anyarray, r anymultirange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anymultirange_func(ARRAY[1,2], int4multirange(int4range(10,20)));
@@ -641,27 +641,27 @@ drop function anyarray_anymultirange_func(anyarray, anymultirange);
-- should fail
create function bogus_func(anyelement)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
-- should fail
create function bogus_func(int)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
create function range_add_bounds(anymultirange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4multirange(int4range(1, 17)));
select range_add_bounds(nummultirange(numrange(1.0001, 123.123)));
create function multirangetypes_sql(q anymultirange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select multirangetypes_sql(int4multirange(int4range(1,10)), ARRAY[2,20]);
select multirangetypes_sql(nummultirange(numrange(1,10)), ARRAY[2,20]); -- match failure
create function anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompatiblemultirange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(int4range(10,20)));
@@ -673,7 +673,7 @@ select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1.1,2], multirange(
drop function anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemultirange);
create function anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompatiblemultirange)
- returns anycompatible as 'select lower($1) + lower($2);' language sql;
+ returns anycompatible as 'select lower($1) + lower($2);' LANGUAGE SQLTEST;
select anycompatiblerange_anycompatiblemultirange_func(int4range(1,2), multirange(int4range(10,20)));
@@ -684,7 +684,7 @@ drop function anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
--
-- Arrays of multiranges
@@ -737,36 +737,36 @@ reset enable_sort;
-- infer anymultirange from anymultirange
create function mr_outparam_succeed(i anymultirange, out r anymultirange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed(int4multirange(int4range(1,2)));
-- infer anyarray from anymultirange
create function mr_outparam_succeed2(i anymultirange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed2(int4multirange(int4range(1,2)));
-- infer anyrange from anymultirange
create function mr_outparam_succeed3(i anymultirange, out r anyrange, out t text)
- as $$ select range_merge($1), 'foo'::text $$ language sql;
+ as $$ select range_merge($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed3(int4multirange(int4range(1,2)));
-- infer anymultirange from anyrange
create function mr_outparam_succeed4(i anyrange, out r anymultirange, out t text)
- as $$ select multirange($1), 'foo'::text $$ language sql;
+ as $$ select multirange($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed4(int4range(1,2));
-- infer anyelement from anymultirange
create function mr_inoutparam_succeed(out i anyelement, inout r anymultirange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from mr_inoutparam_succeed(int4multirange(int4range(1,2)));
-- infer anyelement+anymultirange from anyelement+anymultirange
create function mr_table_succeed(i anyelement, r anymultirange) returns table(i anyelement, r anymultirange)
- as $$ select $1, $2 $$ language sql;
+ as $$ select $1, $2 $$ LANGUAGE SQLTEST;
select * from mr_table_succeed(123, int4multirange(int4range(1,11)));
@@ -777,12 +777,12 @@ select mr_polymorphic(int4range(1, 4));
-- should fail
create function mr_outparam_fail(i anyelement, out r anymultirange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
--should fail
create function mr_inoutparam_fail(inout i anyelement, out r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
--should fail
create function mr_table_fail(i anyelement) returns table(i anyelement, r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
diff --git a/src/test/regress/sql/object_address.sql b/src/test/regress/sql/object_address.sql
index 2f4f66e3e1..7926fb77c6 100644
--- a/src/test/regress/sql/object_address.sql
+++ b/src/test/regress/sql/object_address.sql
@@ -35,14 +35,14 @@ CREATE DOMAIN addr_nsp.gendomain AS int4 CONSTRAINT domconstr CHECK (value > 0);
CREATE FUNCTION addr_nsp.trig() RETURNS TRIGGER LANGUAGE plpgsql AS $$ BEGIN END; $$;
CREATE TRIGGER t BEFORE INSERT ON addr_nsp.gentable FOR EACH ROW EXECUTE PROCEDURE addr_nsp.trig();
CREATE POLICY genpol ON addr_nsp.gentable;
-CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQL AS $$ $$;
+CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQLTEST AS $$ $$;
CREATE SERVER "integer" FOREIGN DATA WRAPPER addr_fdw;
CREATE USER MAPPING FOR regress_addr_user SERVER "integer";
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regress_addr_user;
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM regress_addr_user;
-- this transform would be quite unsafe to leave lying around,
-- except that the SQL language pays no attention to transforms:
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
-- suppress warning that depends on wal_level
@@ -271,7 +271,7 @@ WITH objects (classid, objid, objsubid) AS (VALUES
('pg_policy'::regclass, 0, 0), -- no policy
('pg_publication'::regclass, 0, 0), -- no publication
('pg_publication_rel'::regclass, 0, 0), -- no publication relation
- ('pg_subscription'::regclass, 0, 0), -- no subscription
+ ('pg_sub'::regclass, 0, 0), -- no subscription
('pg_transform'::regclass, 0, 0) -- no transformation
)
SELECT ROW(pg_identify_object(objects.classid, objects.objid, objects.objsubid))
diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql
index 781666a83a..2d1bb17554 100644
--- a/src/test/regress/sql/plpgsql.sql
+++ b/src/test/regress/sql/plpgsql.sql
@@ -3610,11 +3610,11 @@ $$ language plpgsql;
-- "limit" is to prevent this from being inlined
create function sql_recurse(float8) returns float8 as
-$$ select recurse($1) limit 1; $$ language sql;
+$$ select recurse($1) limit 1; $$ LANGUAGE SQLTEST;
select recurse(10);
-create function error1(text) returns text language sql as
+create function error1(text) returns text LANGUAGE SQLTEST as
$$ SELECT relname::text FROM pg_class c WHERE c.oid = $1::regclass $$;
create function error2(p_name_table text) returns text language plpgsql as $$
@@ -3637,7 +3637,7 @@ drop function error1(text);
create function sql_to_date(integer) returns date as $$
select $1::text::date
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
create cast (integer as date) with function sql_to_date(integer) as assignment;
diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/polymorphism.sql
index 891b023ada..5529f99671 100644
--- a/src/test/regress/sql/polymorphism.sql
+++ b/src/test/regress/sql/polymorphism.sql
@@ -5,7 +5,7 @@
create function polyf(x anyelement) returns anyelement as $$
select x + 1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
select polyf(point(3,4)); -- fail for lack of + operator
@@ -14,7 +14,7 @@ drop function polyf(x anyelement);
create function polyf(x anyelement) returns anyarray as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
@@ -22,7 +22,7 @@ drop function polyf(x anyelement);
create function polyf(x anyarray) returns anyelement as $$
select x[1]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
@@ -32,7 +32,7 @@ drop function polyf(x anyarray);
create function polyf(x anyarray) returns anyarray as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
@@ -43,11 +43,11 @@ drop function polyf(x anyarray);
-- fail, can't infer type:
create function polyf(x anyelement) returns anyrange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function polyf(x anyrange) returns anyarray as $$
select array[lower(x), upper(x)]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num;
@@ -55,7 +55,7 @@ drop function polyf(x anyrange);
create function polyf(x anycompatible, y anycompatible) returns anycompatiblearray as $$
select array[x, y]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(2, 4) as int, polyf(2, 4.5) as num;
@@ -63,7 +63,7 @@ drop function polyf(x anycompatible, y anycompatible);
create function polyf(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), 11, 2::smallint) as int, polyf(float8range(4.5, 7.8), 7.8, 11::real) as num;
@@ -73,7 +73,7 @@ drop function polyf(x anycompatiblerange, y anycompatible, z anycompatible);
create function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), 11, 2::smallint) as int, polyf(multirange(float8range(4.5, 7.8)), 7.8, 11::real) as num;
@@ -84,11 +84,11 @@ drop function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible)
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblerange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function polyf(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), array[11]) as int, polyf(float8range(4.5, 7.8), array[7]) as num;
@@ -97,11 +97,11 @@ drop function polyf(x anycompatiblerange, y anycompatiblearray);
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblemultirange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function polyf(x anycompatiblemultirange, y anycompatiblearray) returns anycompatiblemultirange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), array[11]) as int, polyf(multirange(float8range(4.5, 7.8)), array[7]) as num;
@@ -112,7 +112,7 @@ create function polyf(a anyelement, b anyarray,
OUT x anyarray, OUT y anycompatiblearray)
as $$
select a || b, array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x), y, pg_typeof(y)
from polyf(11, array[1, 2], 42, 34.5);
@@ -166,35 +166,35 @@ drop function polyf(a anyelement, b anyarray,
-- polymorphic single arg transfn
CREATE FUNCTION stfp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- non-polymorphic single arg transfn
CREATE FUNCTION stfnp(int[]) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- dual polymorphic transfn
CREATE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- dual non-polymorphic transfn
CREATE FUNCTION tfnp(int[],int) RETURNS int[] AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- arg1 only polymorphic transfn
CREATE FUNCTION tf1p(anyarray,int) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- arg2 only polymorphic transfn
CREATE FUNCTION tf2p(int[],anyelement) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- multi-arg polymorphic
CREATE FUNCTION sum3(anyelement,anyelement,anyelement) returns anyelement AS
-'select $1+$2+$3' language sql strict;
+'select $1+$2+$3' LANGUAGE SQLTEST strict;
-- finalfn polymorphic
CREATE FUNCTION ffp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- finalfn non-polymorphic
CREATE FUNCTION ffnp(int[]) returns int[] as
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- Try to cover all the possible states:
--
@@ -511,7 +511,7 @@ begin
end$$ language plpgsql;
create function sql_if(bool, anyelement, anyelement) returns anyelement as $$
-select case when $1 then $2 else $3 end $$ language sql;
+select case when $1 then $2 else $3 end $$ LANGUAGE SQLTEST;
-- Note this would fail with integer overflow, never mind wrong bleat() output,
-- if the CASE expression were not successfully inlined
@@ -573,10 +573,10 @@ create aggregate build_group(int8, integer) (
-- check proper resolution of data types for polymorphic transfn/finalfn
create function first_el_transfn(anyarray, anyelement) returns anyarray as
-'select $1 || $2' language sql immutable;
+'select $1 || $2' LANGUAGE SQLTEST immutable;
create function first_el(anyarray) returns anyelement as
-'select $1[1]' language sql strict immutable;
+'select $1[1]' LANGUAGE SQLTEST strict immutable;
create aggregate first_el_agg_f8(float8) (
SFUNC = array_append,
@@ -612,7 +612,7 @@ select anyrange_in('[10,20)','int4range'::regtype,-1);
create function myleast(variadic anyarray) returns anyelement as $$
select min($1[i]) from generate_subscripts($1,1) g(i)
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select myleast(10, 1, 20, 33);
select myleast(1.1, 0.22, 0.55);
@@ -629,7 +629,7 @@ select myleast(variadic array[]::int[]);
-- an example with some ordinary arguments too
create function concat(text, variadic anyarray) returns text as $$
select array_to_string($2, $1);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select concat('%', 1, 2, 3, 4, 5);
select concat('|', 'a'::text, 'b', 'c');
@@ -641,7 +641,7 @@ drop function concat(text, anyarray);
-- mix variadic with anyelement
create function formarray(anyelement, variadic anyarray) returns anyarray as $$
select array_prepend($1, $2);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select formarray(1,2,3,4,5);
select formarray(1.1, variadic array[1.2,55.5]);
@@ -667,7 +667,7 @@ select pg_typeof(myleast(10, 1, 20, 33)); -- polymorphic input
-- test basic functionality
create function dfunc(a int = 1, int = 2) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
select dfunc(10);
@@ -681,12 +681,12 @@ drop function dfunc(int, int); -- ok
-- fail: defaults must be at end of argument list
create function dfunc(a int = 1, b int) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- however, this should work:
create function dfunc(a int = 1, out sum int, b int = 2) as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
@@ -698,12 +698,12 @@ drop function dfunc(int, int);
-- check implicit coercion
create function dfunc(a int DEFAULT 1.0, int DEFAULT '-1') returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
create function dfunc(a text DEFAULT 'Hello', b text DEFAULT 'World') returns text as $$
select $1 || ', ' || $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(); -- fail: which dfunc should be called? int or text
select dfunc('Hi'); -- ok
@@ -716,11 +716,11 @@ drop function dfunc(text, text);
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2, int = 3, int = 4) returns int as $$
select 4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- Now, dfunc(nargs = 2) and dfunc(nargs = 4) are ambiguous when called
-- with 0 to 2 arguments.
@@ -737,12 +737,12 @@ drop function dfunc(int, int, int, int);
-- default values are not allowed for output parameters
create function dfunc(out int = 20) returns int as $$
select 1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- polymorphic parameter test
create function dfunc(anyelement = 'World'::text) returns text as $$
select 'Hello, ' || $1::text;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
select dfunc(0);
@@ -754,14 +754,14 @@ drop function dfunc(anyelement);
-- check defaults for variadics
create function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- fail
select dfunc(10);
select dfunc(10,20);
create or replace function dfunc(a variadic int[] default array[]::int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- now ok
select dfunc(10);
@@ -769,7 +769,7 @@ select dfunc(10,20);
-- can't remove the default once it exists
create or replace function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
\df dfunc
@@ -779,15 +779,15 @@ drop function dfunc(a variadic int[]);
create function dfunc(int = 1, int = 2, int = 3) returns int as $$
select 3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(text) returns text as $$
select $1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- dfunc(narg=2) and dfunc(narg=3) are ambiguous
select dfunc(1); -- fail
@@ -806,7 +806,7 @@ drop function dfunc(text);
create function dfunc(a int, b int, c int = 0, d int = 0)
returns table (a int, b int, c int, d int) as $$
select $1, $2, $3, $4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc(10,20,30)).*;
select (dfunc(a := 10, b := 20, c := 30)).*;
@@ -829,7 +829,7 @@ drop function dfunc(int, int, int, int);
create function dfunc(a varchar, b numeric, c date = current_date)
returns table (a varchar, b numeric, c date) as $$
select $1, $2, $3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc('Hello World', 20, '2009-07-25'::date)).*;
select * from dfunc('Hello World', 20, '2009-07-25'::date);
@@ -844,7 +844,7 @@ drop function dfunc(varchar, numeric, date);
create function dfunc(a varchar = 'def a', out _a varchar, c numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc()).*;
select * from dfunc();
@@ -859,26 +859,26 @@ select * from dfunc(c := 100);
create or replace function dfunc(a varchar = 'def a', out _a varchar, x numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create or replace function dfunc(a varchar = 'def a', out _a varchar, numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
drop function dfunc(varchar, numeric);
--fail, named parameters are not unique
-create function testpolym(a int, a int) returns int as $$ select 1;$$ language sql;
-create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ language sql;
-create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ language sql;
-create function testpolym(a int, inout a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(a int, a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
+create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
+create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
+create function testpolym(a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
-- valid
-create function testpolym(a int, out a int) returns int as $$ select $1;$$ language sql;
+create function testpolym(a int, out a int) returns int as $$ select $1;$$ LANGUAGE SQLTEST;
select testpolym(37);
drop function testpolym(int);
-create function testpolym(a int) returns table(a int) as $$ select $1;$$ language sql;
+create function testpolym(a int) returns table(a int) as $$ select $1;$$ LANGUAGE SQLTEST;
select * from testpolym(37);
drop function testpolym(int);
@@ -886,7 +886,7 @@ drop function testpolym(int);
create function dfunc(a anyelement, b anyelement = null, flag bool = true)
returns anyelement as $$
select case when $3 then $1 else $2 end;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(1,2);
select dfunc('a'::text, 'b'); -- positional notation with default
@@ -957,7 +957,7 @@ drop function dfunc(anyelement, anyelement, bool);
create function anyctest(anycompatible, anycompatible)
returns anycompatible as $$
select greatest($1, $2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.3) x;
@@ -969,7 +969,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatible)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.3) x;
@@ -980,7 +980,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatiblearray)
returns anycompatiblearray as $$
select array[$1] || $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[12]) x;
select x, pg_typeof(x) from anyctest(11, array[12.3]) x;
@@ -994,7 +994,7 @@ drop function anyctest(anycompatible, anycompatiblearray);
create function anyctest(anycompatible, anycompatiblerange)
returns anycompatiblerange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, int4range(4,7)) x;
select x, pg_typeof(x) from anyctest(11, numrange(4,7)) x;
@@ -1007,7 +1007,7 @@ drop function anyctest(anycompatible, anycompatiblerange);
create function anyctest(anycompatiblerange, anycompatiblerange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(int4range(11,12), int4range(4,7)) x;
select x, pg_typeof(x) from anyctest(int4range(11,12), numrange(4,7)) x; -- fail
@@ -1018,12 +1018,12 @@ drop function anyctest(anycompatiblerange, anycompatiblerange);
create function anyctest(anycompatible)
returns anycompatiblerange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function anyctest(anycompatible, anycompatiblemultirange)
returns anycompatiblemultirange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, multirange(int4range(4,7))) x;
select x, pg_typeof(x) from anyctest(11, multirange(numrange(4,7))) x;
@@ -1036,7 +1036,7 @@ drop function anyctest(anycompatible, anycompatiblemultirange);
create function anyctest(anycompatiblemultirange, anycompatiblemultirange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(int4range(4,7))) x;
select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(numrange(4,7))) x; -- fail
@@ -1047,12 +1047,12 @@ drop function anyctest(anycompatiblemultirange, anycompatiblemultirange);
create function anyctest(anycompatible)
returns anycompatiblemultirange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function anyctest(anycompatiblenonarray, anycompatiblenonarray)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.3) x;
@@ -1064,7 +1064,7 @@ create function anyctest(a anyelement, b anyarray,
c anycompatible, d anycompatible)
returns anycompatiblearray as $$
select array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[1, 2], 42, 34.5) x;
select x, pg_typeof(x) from anyctest(11, array[1, 2], point(1,2), point(3,4)) x;
@@ -1077,7 +1077,7 @@ drop function anyctest(a anyelement, b anyarray,
create function anyctest(variadic anycompatiblearray)
returns anycompatiblearray as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.2) x;
diff --git a/src/test/regress/sql/portals.sql b/src/test/regress/sql/portals.sql
index 52560ac027..f540fee4d1 100644
--- a/src/test/regress/sql/portals.sql
+++ b/src/test/regress/sql/portals.sql
@@ -239,7 +239,7 @@ BEGIN;
CREATE FUNCTION declares_cursor(text)
RETURNS void
AS 'DECLARE c CURSOR FOR SELECT stringu1 FROM tenk1 WHERE stringu1 LIKE $1;'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT declares_cursor('AB%');
@@ -256,10 +256,10 @@ ROLLBACK;
create temp table tt1(f1 int);
create function count_tt1_v() returns int8 as
-'select count(*) from tt1' language sql volatile;
+'select count(*) from tt1' LANGUAGE SQLTEST volatile;
create function count_tt1_s() returns int8 as
-'select count(*) from tt1' language sql stable;
+'select count(*) from tt1' LANGUAGE SQLTEST stable;
begin;
@@ -512,7 +512,7 @@ DROP TABLE cursor;
-- per bug report in 8336843.9833.1399385291498.JavaMail.root@quick
begin;
create function nochange(int) returns int
- as 'select $1 limit 1' language sql stable;
+ as 'select $1 limit 1' LANGUAGE SQLTEST stable;
declare c cursor for select * from int8_tbl limit nochange(3);
fetch all from c;
move backward all in c;
diff --git a/src/test/regress/sql/privileges.sql b/src/test/regress/sql/privileges.sql
index 4911ad4add..7ca26f1104 100644
--- a/src/test/regress/sql/privileges.sql
+++ b/src/test/regress/sql/privileges.sql
@@ -481,16 +481,16 @@ END;
-- switch to superuser
\c -
-REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user1; -- ok
+REVOKE ALL PRIVILEGES ON LANGUAGE sqltest FROM PUBLIC;
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user1; -- ok
GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
SET SESSION AUTHORIZATION regress_priv_user1;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user2; -- fail
-CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql;
-CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user2; -- fail
+CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest;
+CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE priv_testagg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sql;
+CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sqltest;
REVOKE ALL ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) TO regress_priv_user2;
@@ -507,12 +507,12 @@ GRANT ALL PRIVILEGES ON PROCEDURE priv_testproc1(int) TO regress_priv_user4;
CREATE FUNCTION priv_testfunc4(boolean) RETURNS text
AS 'select col1 from atest2 where col2 = $1;'
- LANGUAGE sql SECURITY DEFINER;
+ LANGUAGE sqltest SECURITY DEFINER;
GRANT EXECUTE ON FUNCTION priv_testfunc4(boolean) TO regress_priv_user3;
SET SESSION AUTHORIZATION regress_priv_user2;
SELECT priv_testfunc1(5), priv_testfunc2(5); -- ok
-CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail
+CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest; -- fail
SELECT priv_testagg1(x) FROM (VALUES (1), (2), (3)) _(x); -- ok
CALL priv_testproc1(6); -- ok
@@ -536,7 +536,7 @@ DROP PROCEDURE priv_testproc1(int); -- fail
DROP FUNCTION priv_testfunc1(int); -- ok
-- restore to sanity
-GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
+GRANT ALL PRIVILEGES ON LANGUAGE sqltest TO PUBLIC;
-- verify privilege checks on array-element coercions
BEGIN;
@@ -572,13 +572,13 @@ CREATE AGGREGATE priv_testagg1a(priv_testdomain1) (sfunc = int4_sum, stype = big
CREATE DOMAIN priv_testdomain2a AS priv_testdomain1;
CREATE DOMAIN priv_testdomain3a AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3a) WITH FUNCTION castfunc(int);
DROP FUNCTION castfunc(int) CASCADE;
DROP DOMAIN priv_testdomain3a;
-CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
-CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
CREATE OPERATOR !+! (PROCEDURE = int4pl, LEFTARG = priv_testdomain1, RIGHTARG = priv_testdomain1);
@@ -609,11 +609,11 @@ CREATE AGGREGATE priv_testagg1b(priv_testdomain1) (sfunc = int4_sum, stype = big
CREATE DOMAIN priv_testdomain2b AS priv_testdomain1;
CREATE DOMAIN priv_testdomain3b AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3b) WITH FUNCTION castfunc(int);
-CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
-CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
CREATE OPERATOR !! (PROCEDURE = priv_testfunc5b, RIGHTARG = priv_testdomain1);
@@ -813,9 +813,9 @@ SELECT has_table_privilege('regress_priv_user1', 'atest4', 'SELECT WITH GRANT OP
CREATE ROLE regress_sro_user;
SET SESSION AUTHORIZATION regress_sro_user;
-CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sql AS
+CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sqltest AS
'GRANT regress_priv_group2 TO regress_sro_user';
-CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'DECLARE c CURSOR WITH HOLD FOR SELECT unwanted_grant(); SELECT true';
-- REFRESH of this MV will queue a GRANT at end of transaction
CREATE MATERIALIZED VIEW sro_mv AS SELECT mv_action() WITH NO DATA;
@@ -831,7 +831,7 @@ CREATE FUNCTION sro_trojan() RETURNS trigger LANGUAGE plpgsql AS
CREATE CONSTRAINT TRIGGER t AFTER INSERT ON sro_trojan_table
INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE sro_trojan();
-- Now, REFRESH will issue such an INSERT, queueing the GRANT
-CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'INSERT INTO sro_trojan_table DEFAULT VALUES; SELECT true';
REFRESH MATERIALIZED VIEW sro_mv;
\c -
@@ -845,7 +845,7 @@ DROP ROLE regress_sro_user;
-- Admin options
SET SESSION AUTHORIZATION regress_priv_user4;
-CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: had ADMIN OPTION
SET ROLE regress_priv_group2;
@@ -859,7 +859,7 @@ GRANT regress_priv_group2 TO regress_priv_user5; -- fails: SET ROLE did not help
SET SESSION AUTHORIZATION regress_priv_group2;
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: a role can self-admin
-CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
SELECT dogrant_fails(); -- fails: no self-admin in SECURITY DEFINER
DROP FUNCTION dogrant_fails();
@@ -1055,9 +1055,9 @@ SELECT has_schema_privilege('regress_priv_user2', 'testns5', 'CREATE'); -- no
SET ROLE regress_priv_user1;
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- no
SELECT has_function_privilege('regress_priv_user2', 'testns.agg1(int)', 'EXECUTE'); -- no
@@ -1066,11 +1066,11 @@ SELECT has_function_privilege('regress_priv_user2', 'testns.bar()', 'EXECUTE');
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT EXECUTE ON ROUTINES to public;
DROP FUNCTION testns.foo();
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
DROP AGGREGATE testns.agg1(int);
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
DROP PROCEDURE testns.bar();
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- yes
SELECT has_function_privilege('regress_priv_user2', 'testns.agg1(int)', 'EXECUTE'); -- yes
@@ -1131,9 +1131,9 @@ REVOKE ALL ON ALL TABLES IN SCHEMA testns FROM regress_priv_user1;
SELECT has_table_privilege('regress_priv_user1', 'testns.t1', 'SELECT'); -- false
SELECT has_table_privilege('regress_priv_user1', 'testns.t2', 'SELECT'); -- false
-CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE testns.priv_testagg(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sql;
+CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user1', 'testns.priv_testfunc(int)', 'EXECUTE'); -- true by default
SELECT has_function_privilege('regress_priv_user1', 'testns.priv_testagg(int)', 'EXECUTE'); -- true by default
@@ -1242,7 +1242,7 @@ DROP GROUP regress_priv_group1;
DROP GROUP regress_priv_group2;
-- these are needed to clean up permissions
-REVOKE USAGE ON LANGUAGE sql FROM regress_priv_user1;
+REVOKE USAGE ON LANGUAGE sqltest FROM regress_priv_user1;
DROP OWNED BY regress_priv_user1;
DROP USER regress_priv_user1;
diff --git a/src/test/regress/sql/rangefuncs.sql b/src/test/regress/sql/rangefuncs.sql
index 3c436028da..6ab1f10b01 100644
--- a/src/test/regress/sql/rangefuncs.sql
+++ b/src/test/regress/sql/rangefuncs.sql
@@ -3,7 +3,7 @@ INSERT INTO rngfunc2 VALUES(1, 11);
INSERT INTO rngfunc2 VALUES(2, 22);
INSERT INTO rngfunc2 VALUES(1, 111);
-CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQL;
+CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQLTEST;
-- function with ORDINALITY
select * from rngfunct(1) with ordinality as z(a,b,ord);
@@ -88,7 +88,7 @@ INSERT INTO rngfunc VALUES(1,2,'Ed');
INSERT INTO rngfunc VALUES(2,1,'Mary');
-- sql, proretset = f, prorettype = b
-CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc1(1) AS t1;
SELECT * FROM getrngfunc1(1) WITH ORDINALITY AS t1(v,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc1(1);
@@ -99,7 +99,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc2(1) AS t1;
SELECT * FROM getrngfunc2(1) WITH ORDINALITY AS t1(v,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc2(1);
@@ -110,7 +110,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc3(1) AS t1;
SELECT * FROM getrngfunc3(1) WITH ORDINALITY AS t1(v,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc3(1);
@@ -121,7 +121,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = c
-CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc4(1) AS t1;
SELECT * FROM getrngfunc4(1) WITH ORDINALITY AS t1(a,b,c,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc4(1);
@@ -132,7 +132,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = c
-CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc5(1) AS t1;
SELECT * FROM getrngfunc5(1) WITH ORDINALITY AS t1(a,b,c,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc5(1);
@@ -143,7 +143,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = record
-CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc6(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
SELECT * FROM ROWS FROM( getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY;
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc6(1) AS
@@ -157,7 +157,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = record
-CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc7(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
SELECT * FROM ROWS FROM( getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY;
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc7(1) AS
@@ -232,7 +232,7 @@ CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq1;
CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq2;
CREATE TYPE rngfunc_rescan_t AS (i integer, s bigint);
-CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQL;
+CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQLTEST;
-- plpgsql functions use materialize mode
CREATE FUNCTION rngfunc_mat(int,int) RETURNS setof rngfunc_rescan_t AS 'begin for i in $1..$2 loop return next (i, nextval(''rngfunc_rescan_seq2'')); end loop; end;' LANGUAGE plpgsql;
@@ -344,32 +344,32 @@ DROP SEQUENCE rngfunc_rescan_seq2;
--
CREATE FUNCTION rngfunc(in f1 int, out f2 int)
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
SELECT rngfunc(42);
SELECT * FROM rngfunc(42);
SELECT * FROM rngfunc(42) AS p(x);
-- explicit spec of return type is OK
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
-- error, wrong result type
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS float
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
-- with multiple OUT params you must get a RECORD result
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text)
RETURNS record
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
CREATE OR REPLACE FUNCTION rngfuncr(in f1 int, out f2 int, out text)
-AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncr(f1) FROM int4_tbl;
SELECT * FROM rngfuncr(42);
SELECT * FROM rngfuncr(42) AS p(a,b);
CREATE OR REPLACE FUNCTION rngfuncb(in f1 int, inout f2 int, out text)
-AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncb(f1, f1/2) FROM int4_tbl;
SELECT * FROM rngfuncb(42, 99);
SELECT * FROM rngfuncb(42, 99) AS p(a,b);
@@ -384,7 +384,7 @@ DROP FUNCTION rngfuncb(in f1 int, inout f2 int);
--
CREATE FUNCTION dup (f1 anyelement, f2 out anyelement, f3 out anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
SELECT dup('xyz'); -- fails
SELECT dup('xyz'::text);
@@ -392,23 +392,23 @@ SELECT * FROM dup('xyz'::text);
-- fails, as we are attempting to rename first argument
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
DROP FUNCTION dup(anyelement);
-- equivalent behavior, though different name exposed for input arg
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
DROP FUNCTION dup(anyelement);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 int, out f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
CREATE FUNCTION dup (f1 anycompatible, f2 anycompatiblearray, f3 out anycompatible, f4 out anycompatiblearray)
-AS 'select $1, $2' LANGUAGE sql;
+AS 'select $1, $2' LANGUAGE sqltest;
SELECT dup(22, array[44]);
SELECT dup(4.5, array[44]);
SELECT dup(22, array[44::bigint]);
@@ -417,7 +417,7 @@ SELECT *, pg_typeof(f3), pg_typeof(f4) FROM dup(22, array[44::bigint]);
DROP FUNCTION dup(f1 anycompatible, f2 anycompatiblearray);
CREATE FUNCTION dup (f1 anycompatiblerange, f2 out anycompatible, f3 out anycompatiblearray, f4 out anycompatiblerange)
-AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sql;
+AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sqltest;
SELECT dup(int4range(4,7));
SELECT dup(numrange(4,7));
SELECT dup(textrange('aaa', 'bbb'));
@@ -426,7 +426,7 @@ DROP FUNCTION dup(f1 anycompatiblerange);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 anyarray, out f2 anycompatible, out f3 anycompatiblearray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
--
-- table functions
@@ -434,7 +434,7 @@ AS 'select $1, array[$1,$1]' LANGUAGE sql;
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a int)
-AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sql;
+AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc();
DROP FUNCTION rngfunc();
@@ -442,14 +442,14 @@ CREATE OR REPLACE FUNCTION rngfunc(int)
RETURNS TABLE(a int, b int)
AS $$ SELECT a, b
FROM generate_series(1,$1) a(a),
- generate_series(1,$1) b(b) $$ LANGUAGE sql;
+ generate_series(1,$1) b(b) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc(3);
DROP FUNCTION rngfunc(int);
-- case that causes change of typmod knowledge during inlining
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a varchar(5))
-AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sql STABLE;
+AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sqltest STABLE;
SELECT * FROM rngfunc() GROUP BY 1;
DROP FUNCTION rngfunc();
@@ -461,7 +461,7 @@ create temp table tt(f1 serial, data text);
create function insert_tt(text) returns int as
$$ insert into tt(data) values($1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('foo');
select insert_tt('bar');
@@ -470,7 +470,7 @@ select * from tt;
-- insert will execute to completion even if function needs just 1 row
create or replace function insert_tt(text) returns int as
$$ insert into tt(data) values($1),($1||$1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('fool');
select * from tt;
@@ -478,7 +478,7 @@ select * from tt;
-- setof does what's expected
create or replace function insert_tt2(text,text) returns setof int as
$$ insert into tt(data) values($1),($2) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt2('foolish','barrish');
select * from insert_tt2('baz','quux');
@@ -515,7 +515,7 @@ select * from tt_log;
-- test case for a whole-row-variable bug
create function rngfunc1(n integer, out a text, out b text)
returns setof record
- language sql
+ LANGUAGE SQLTEST
as $$ select 'foo ' || i, 'bar ' || i from generate_series(1,$1) i $$;
set work_mem='64kB';
@@ -531,7 +531,7 @@ drop function rngfunc1(n integer);
create function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql strict immutable;
+$$ LANGUAGE SQLTEST strict immutable;
select array_to_set(array['one', 'two']);
select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text);
@@ -549,7 +549,7 @@ explain (verbose, costs off)
create or replace function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select array_to_set(array['one', 'two']);
select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text);
@@ -562,7 +562,7 @@ create temp table rngfunc(f1 int8, f2 int8);
create function testrngfunc() returns record as $$
insert into rngfunc values (1,2) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
select * from testrngfunc() as t(f1 int8,f2 int8);
@@ -572,7 +572,7 @@ drop function testrngfunc();
create function testrngfunc() returns setof record as $$
insert into rngfunc values (1,2), (3,4) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
select * from testrngfunc() as t(f1 int8,f2 int8);
@@ -585,7 +585,7 @@ create type rngfunc_type as (f1 numeric(35,6), f2 numeric(35,2));
create function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
@@ -596,7 +596,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
@@ -609,7 +609,7 @@ drop function testrngfunc();
create function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
@@ -620,7 +620,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
@@ -631,7 +631,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 1, 2 union select 3, 4 order by 1;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
@@ -658,14 +658,14 @@ alter table users drop column todrop;
create or replace function get_first_user() returns users as
$$ SELECT * FROM users ORDER BY userid LIMIT 1; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_first_user();
SELECT * FROM get_first_user();
create or replace function get_users() returns setof users as
$$ SELECT * FROM users ORDER BY userid; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_users();
SELECT * FROM get_users();
@@ -698,7 +698,7 @@ drop table users;
create or replace function rngfuncbar() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar ; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select rngfuncbar();
select * from rngfuncbar();
@@ -710,17 +710,17 @@ drop function rngfuncbar();
-- check handling of a SQL function with multiple OUT params (bug #5777)
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1) $$ language sql;
+$$ select (1, 2.1) $$ LANGUAGE SQLTEST;
select * from rngfuncbar();
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2) $$ language sql;
+$$ select (1, 2) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1, 3) $$ language sql;
+$$ select (1, 2.1, 3) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
@@ -730,7 +730,7 @@ drop function rngfuncbar();
create function extractq2(t int8_tbl) returns int8 as $$
select t.q2
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2(int8_tbl) f(x);
@@ -739,7 +739,7 @@ select x from int8_tbl, extractq2(int8_tbl) f(x);
create function extractq2_2(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t) offset 0
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2(int8_tbl) f(x);
@@ -750,7 +750,7 @@ select x from int8_tbl, extractq2_2(int8_tbl) f(x);
create function extractq2_2_opt(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t)
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x);
diff --git a/src/test/regress/sql/rangetypes.sql b/src/test/regress/sql/rangetypes.sql
index e1b8917c0c..a65130f78b 100644
--- a/src/test/regress/sql/rangetypes.sql
+++ b/src/test/regress/sql/rangetypes.sql
@@ -465,7 +465,7 @@ drop type textrange2;
--
create function anyarray_anyrange_func(a anyarray, r anyrange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anyrange_func(ARRAY[1,2], int4range(10,20));
@@ -476,27 +476,27 @@ drop function anyarray_anyrange_func(anyarray, anyrange);
-- should fail
create function bogus_func(anyelement)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
-- should fail
create function bogus_func(int)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
create function range_add_bounds(anyrange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4range(1, 17));
select range_add_bounds(numrange(1.0001, 123.123));
create function rangetypes_sql(q anyrange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select rangetypes_sql(int4range(1,10), ARRAY[2,20]);
select rangetypes_sql(numrange(1,10), ARRAY[2,20]); -- match failure
create function anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatiblerange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], int4range(10,20));
@@ -509,7 +509,7 @@ drop function anycompatiblearray_anycompatiblerange_func(anycompatiblearray, any
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
--
-- Arrays of ranges
@@ -569,43 +569,43 @@ reset enable_sort;
-- infer anyrange from anyrange
create function outparam_succeed(i anyrange, out r anyrange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed(int4range(1,2));
create function outparam2_succeed(r anyrange, out lu anyarray, out ul anyarray)
as $$ select array[lower($1), upper($1)], array[upper($1), lower($1)] $$
- language sql;
+ LANGUAGE SQLTEST;
select * from outparam2_succeed(int4range(1,11));
-- infer anyarray from anyrange
create function outparam_succeed2(i anyrange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed2(int4range(int4range(1,2)));
-- infer anyelement from anyrange
create function inoutparam_succeed(out i anyelement, inout r anyrange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from inoutparam_succeed(int4range(1,2));
create function table_succeed(r anyrange)
returns table(l anyelement, u anyelement)
as $$ select lower($1), upper($1) $$
- language sql;
+ LANGUAGE SQLTEST;
select * from table_succeed(int4range(1,11));
-- should fail
create function outparam_fail(i anyelement, out r anyrange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
--should fail
create function inoutparam_fail(inout i anyelement, out r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
--should fail
create function table_fail(i anyelement) returns table(i anyelement, r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
diff --git a/src/test/regress/sql/rowtypes.sql b/src/test/regress/sql/rowtypes.sql
index 845e3305f3..d5613d287c 100644
--- a/src/test/regress/sql/rowtypes.sql
+++ b/src/test/regress/sql/rowtypes.sql
@@ -331,11 +331,11 @@ CREATE TYPE price_key AS (
CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
insert into price values (1,false,42), (10,false,100), (11,true,17.99);
@@ -357,19 +357,19 @@ create temp table compos (f1 int, f2 text);
create function fcompos1(v compos) returns void as $$
insert into compos values (v); -- fail
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos1(v compos) returns void as $$
insert into compos values (v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos2(v compos) returns void as $$
select fcompos1(v);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos3(v compos) returns void as $$
select fcompos1(fcompos3.v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select fcompos1(row(1,'one'));
select fcompos2(row(2,'two'));
@@ -399,7 +399,7 @@ insert into fullname values ('Joe', 'Blow');
select f.last from fullname f;
select last(f) from fullname f;
-create function longname(fullname) returns text language sql
+create function longname(fullname) returns text LANGUAGE SQLTEST
as $$select $1.first || ' ' || $1.last$$;
select f.longname from fullname f;
diff --git a/src/test/regress/sql/rules.sql b/src/test/regress/sql/rules.sql
index 744cf7ab54..832bf45356 100644
--- a/src/test/regress/sql/rules.sql
+++ b/src/test/regress/sql/rules.sql
@@ -431,7 +431,7 @@ create view rtest_vview4 as select X.a, X.b, count(Y.a) as refcount
group by X.a, X.b;
create function rtest_viewfunc1(int4) returns int4 as
'select count(*)::int4 from rtest_view2 where a = $1'
- language sql;
+ LANGUAGE SQLTEST;
create view rtest_vview5 as select a, b, rtest_viewfunc1(a) as refcount
from rtest_view1;
@@ -1174,7 +1174,7 @@ drop table hat_data;
-- Note that the function is kept around to stress pg_dump.
CREATE FUNCTION func_with_set_params() RETURNS integer
AS 'select 1;'
- LANGUAGE SQL
+ LANGUAGE SQLTEST
SET search_path TO PG_CATALOG
SET extra_float_digits TO 2
SET work_mem TO '4MB'
diff --git a/src/test/regress/sql/select.sql b/src/test/regress/sql/select.sql
index b5929b2eca..30cbc2e0e7 100644
--- a/src/test/regress/sql/select.sql
+++ b/src/test/regress/sql/select.sql
@@ -243,7 +243,7 @@ SELECT 1 AS x ORDER BY x;
-- But ORDER BY on a set-valued expression does
create function sillysrf(int) returns setof int as
- 'values (1),(10),(2),($1)' language sql immutable;
+ 'values (1),(10),(2),($1)' LANGUAGE SQLTEST immutable;
select sillysrf(42);
select sillysrf(-1) order by 1;
diff --git a/src/test/regress/sql/select_into.sql b/src/test/regress/sql/select_into.sql
index 7e903c339a..5dbf9cbe9f 100644
--- a/src/test/regress/sql/select_into.sql
+++ b/src/test/regress/sql/select_into.sql
@@ -90,7 +90,7 @@ DROP TABLE ctas_nodata_4;
CREATE FUNCTION make_table() RETURNS VOID
AS $$
CREATE TABLE created_table AS SELECT * FROM int8_tbl;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
SELECT make_table();
diff --git a/src/test/regress/sql/select_parallel.sql b/src/test/regress/sql/select_parallel.sql
index 5a01a98b26..705a4d9478 100644
--- a/src/test/regress/sql/select_parallel.sql
+++ b/src/test/regress/sql/select_parallel.sql
@@ -52,7 +52,7 @@ reset enable_parallel_append;
-- Parallel Append that runs serially
create function sp_test_func() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select sp_test_func() order by 1;
-- Parallel Append is not to be used when the subpath depends on the outer param
diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql
index 14fa0b247e..4929dbb3bd 100644
--- a/src/test/regress/sql/subscription.sql
+++ b/src/test/regress/sql/subscription.sql
@@ -28,7 +28,7 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB
CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false);
COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription';
-SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
+SELECT obj_description(s.oid, 'pg_sub') FROM pg_sub s;
-- fail - name already exists
CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false);
diff --git a/src/test/regress/sql/subselect.sql b/src/test/regress/sql/subselect.sql
index bd17f5d264..1f00fc0f5a 100644
--- a/src/test/regress/sql/subselect.sql
+++ b/src/test/regress/sql/subselect.sql
@@ -481,7 +481,7 @@ begin;
-- make an operator to allow it to succeed
create function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2';
create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text);
@@ -492,7 +492,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function results in unusual number of hash clauses,
-- which we can still cope with
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2 and $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2 and $1::text = $2';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
@@ -501,7 +501,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function causes LHS and RHS to be switched,
-- which we can't cope with, so hashing should be abandoned
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $2 = $1::text';
+LANGUAGE SQLTEST as 'select $2 = $1::text';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
diff --git a/src/test/regress/sql/temp.sql b/src/test/regress/sql/temp.sql
index 424d12b283..abd25c2b85 100644
--- a/src/test/regress/sql/temp.sql
+++ b/src/test/regress/sql/temp.sql
@@ -131,10 +131,10 @@ create temp table whereami (f1 text);
insert into whereami values ('temp');
create function public.whoami() returns text
- as $$select 'public'::text$$ language sql;
+ as $$select 'public'::text$$ LANGUAGE SQLTEST;
create function pg_temp.whoami() returns text
- as $$select 'temp'::text$$ language sql;
+ as $$select 'temp'::text$$ LANGUAGE SQLTEST;
-- default should have pg_temp implicitly first, but only for tables
select * from whereami;
@@ -248,11 +248,11 @@ drop table temp_inh_oncommit_test;
-- Function creation
begin;
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
prepare transaction 'twophase_func';
-- Function drop
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
begin;
drop function pg_temp.twophase_func();
prepare transaction 'twophase_func';
diff --git a/src/test/regress/sql/transactions.sql b/src/test/regress/sql/transactions.sql
index bf1016489d..a7a19adcf0 100644
--- a/src/test/regress/sql/transactions.sql
+++ b/src/test/regress/sql/transactions.sql
@@ -281,7 +281,7 @@ COMMIT;
--
select * from xacttest;
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' stable;
begin;
@@ -290,7 +290,7 @@ select * from xacttest;
rollback;
-- But a volatile function can see the partial results of the calling query
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' volatile;
begin;
diff --git a/src/test/regress/sql/typed_table.sql b/src/test/regress/sql/typed_table.sql
index 9ef0cdfcc7..057b5bd1b6 100644
--- a/src/test/regress/sql/typed_table.sql
+++ b/src/test/regress/sql/typed_table.sql
@@ -7,7 +7,7 @@ SELECT * FROM persons;
\d persons
CREATE FUNCTION get_all_persons() RETURNS SETOF person_type
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT * FROM persons;
$$;
@@ -57,7 +57,7 @@ CREATE TYPE person_type AS (id int, name text);
CREATE TABLE persons OF person_type;
INSERT INTO persons VALUES (1, 'test');
-CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$;
+CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQLTEST AS $$ SELECT length($1.name) $$;
SELECT id, namelen(persons) FROM persons;
CREATE TABLE persons2 OF person_type (
diff --git a/src/test/regress/sql/updatable_views.sql b/src/test/regress/sql/updatable_views.sql
index 09328e582b..47073f1925 100644
--- a/src/test/regress/sql/updatable_views.sql
+++ b/src/test/regress/sql/updatable_views.sql
@@ -394,7 +394,7 @@ INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i);
CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl;
CREATE FUNCTION rw_view1_aa(x rw_view1)
- RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql;
+ RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sqltest;
UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2
RETURNING rw_view1_aa(v), v.bb;
diff --git a/src/test/regress/sql/vacuum.sql b/src/test/regress/sql/vacuum.sql
index c7b5f96f6b..641d4bf16c 100644
--- a/src/test/regress/sql/vacuum.sql
+++ b/src/test/regress/sql/vacuum.sql
@@ -46,9 +46,9 @@ CREATE TABLE vaccluster (i INT PRIMARY KEY);
ALTER TABLE vaccluster CLUSTER ON vaccluster_pkey;
CLUSTER vaccluster;
-CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL
+CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQLTEST
AS 'ANALYZE pg_am';
-CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL
+CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQLTEST
AS 'SELECT $1 FROM do_analyze()';
CREATE INDEX ON vaccluster(wrap_do_analyze(i));
INSERT INTO vaccluster VALUES (1), (2);
diff --git a/src/test/regress/sql/window.sql b/src/test/regress/sql/window.sql
index eae5fa6017..cfcd942488 100644
--- a/src/test/regress/sql/window.sql
+++ b/src/test/regress/sql/window.sql
@@ -982,15 +982,15 @@ SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four
CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE AGGREGATE logging_agg_nonstrict (anyelement)
(
@@ -1014,15 +1014,15 @@ CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement)
CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '*' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '+' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE AGGREGATE logging_agg_strict (text)
(
@@ -1134,7 +1134,7 @@ ORDER BY i;
CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS
$$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$
-LANGUAGE SQL STRICT;
+LANGUAGE SQLTEST STRICT;
CREATE AGGREGATE sum_int_randomrestart (int4)
(
@@ -1324,7 +1324,7 @@ AS $$
SELECT array_agg(s) OVER w
FROM generate_series(1,5) s
WINDOW w AS (ORDER BY s ROWS BETWEEN CURRENT ROW AND GROUP_SIZE FOLLOWING)
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQLTEST STABLE;
EXPLAIN (costs off) SELECT * FROM pg_temp.f(2);
SELECT * FROM pg_temp.f(2);
diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl
index 0680f44a1a..3703478be1 100644
--- a/src/test/subscription/t/001_rep_changes.pl
+++ b/src/test/subscription/t/001_rep_changes.pl
@@ -19,7 +19,7 @@ $node_subscriber->start;
$node_publisher->safe_psql(
'postgres',
"CREATE FUNCTION public.pg_get_replica_identity_index(int)
- RETURNS regclass LANGUAGE sql AS 'SELECT 1/0'"); # shall not call
+ RETURNS regclass LANGUAGE sqltest AS 'SELECT 1/0'"); # shall not call
$node_publisher->safe_psql('postgres',
"CREATE TABLE tab_notrep AS SELECT generate_series(1,10) AS a");
$node_publisher->safe_psql('postgres',
@@ -89,7 +89,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Also wait for initial table sync to finish
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
@@ -336,7 +336,7 @@ $node_publisher->poll_query_until('postgres',
$node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub_renamed");
$result = $node_subscriber->safe_psql('postgres',
- "SELECT count(*) FROM pg_subscription");
+ "SELECT count(*) FROM pg_sub");
is($result, qq(0), 'check subscription was dropped on subscriber');
$result = $node_publisher->safe_psql('postgres',
@@ -344,7 +344,7 @@ $result = $node_publisher->safe_psql('postgres',
is($result, qq(0), 'check replication slot was dropped on publisher');
$result = $node_subscriber->safe_psql('postgres',
- "SELECT count(*) FROM pg_subscription_rel");
+ "SELECT count(*) FROM pg_sub_rel");
is($result, qq(0),
'check subscription relation status was dropped on subscriber');
diff --git a/src/test/subscription/t/002_types.pl b/src/test/subscription/t/002_types.pl
index aedcab2fbc..c25cc34a2c 100644
--- a/src/test/subscription/t/002_types.pl
+++ b/src/test/subscription/t/002_types.pl
@@ -93,7 +93,7 @@ my $ddl = qq(
);
SET check_function_bodies=off;
- CREATE FUNCTION public.monot_incr(int) RETURNS bool LANGUAGE sql
+ CREATE FUNCTION public.monot_incr(int) RETURNS bool LANGUAGE sqltest
AS ' select \$1 > max(a) from public.tst_dom_constr; ';
CREATE DOMAIN monot_int AS int CHECK (monot_incr(VALUE));
CREATE TABLE public.tst_dom_constr (a monot_int););
@@ -115,7 +115,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Wait for initial sync to finish as well
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/004_sync.pl b/src/test/subscription/t/004_sync.pl
index e111ab9181..1d735073fc 100644
--- a/src/test/subscription/t/004_sync.pl
+++ b/src/test/subscription/t/004_sync.pl
@@ -40,7 +40,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Also wait for initial table sync to finish
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
@@ -60,7 +60,7 @@ $node_subscriber->safe_psql('postgres',
);
# but it will be stuck on data copy as it will fail on constraint
-my $started_query = "SELECT srsubstate = 'd' FROM pg_subscription_rel;";
+my $started_query = "SELECT srsubstate = 'd' FROM pg_sub_rel;";
$node_subscriber->poll_query_until('postgres', $started_query)
or die "Timed out while waiting for subscriber to start sync";
@@ -83,7 +83,7 @@ $node_subscriber->safe_psql('postgres',
# wait for it to start
$node_subscriber->poll_query_until('postgres',
- "SELECT pid IS NOT NULL FROM pg_stat_subscription WHERE subname = 'tap_sub2' AND relid IS NULL"
+ "SELECT pid IS NOT NULL FROM pg_stat_sub WHERE subname = 'tap_sub2' AND relid IS NULL"
) or die "Timed out while waiting for subscriber to start";
# and drop both subscriptions
@@ -92,7 +92,7 @@ $node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub2");
# check subscriptions are removed
$result = $node_subscriber->safe_psql('postgres',
- "SELECT count(*) FROM pg_subscription");
+ "SELECT count(*) FROM pg_sub");
is($result, qq(0), 'second and third sub are dropped');
# remove the conflicting data
diff --git a/src/test/subscription/t/005_encoding.pl b/src/test/subscription/t/005_encoding.pl
index aec7a17a78..f62ac885a7 100644
--- a/src/test/subscription/t/005_encoding.pl
+++ b/src/test/subscription/t/005_encoding.pl
@@ -33,7 +33,7 @@ $node_publisher->wait_for_catchup('mysub');
# Wait for initial sync to finish as well
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/006_rewrite.pl b/src/test/subscription/t/006_rewrite.pl
index c6cda10a19..c1d8058f70 100644
--- a/src/test/subscription/t/006_rewrite.pl
+++ b/src/test/subscription/t/006_rewrite.pl
@@ -29,7 +29,7 @@ $node_publisher->wait_for_catchup('mysub');
# Wait for initial sync to finish as well
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/008_diff_schema.pl b/src/test/subscription/t/008_diff_schema.pl
index 963334ed89..cdcff2d695 100644
--- a/src/test/subscription/t/008_diff_schema.pl
+++ b/src/test/subscription/t/008_diff_schema.pl
@@ -39,7 +39,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Also wait for initial table sync to finish
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/010_truncate.pl b/src/test/subscription/t/010_truncate.pl
index be2c0bdc35..ac46e28400 100644
--- a/src/test/subscription/t/010_truncate.pl
+++ b/src/test/subscription/t/010_truncate.pl
@@ -63,7 +63,7 @@ $node_subscriber->safe_psql('postgres',
# Wait for initial sync of all subscriptions
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/011_generated.pl b/src/test/subscription/t/011_generated.pl
index f35d1cba4c..08bc828625 100644
--- a/src/test/subscription/t/011_generated.pl
+++ b/src/test/subscription/t/011_generated.pl
@@ -38,7 +38,7 @@ $node_subscriber->safe_psql('postgres',
# Wait for initial sync of all subscriptions
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/013_partition.pl b/src/test/subscription/t/013_partition.pl
index a04c03a7e2..27c7300ebd 100644
--- a/src/test/subscription/t/013_partition.pl
+++ b/src/test/subscription/t/013_partition.pl
@@ -89,7 +89,7 @@ $node_subscriber2->safe_psql('postgres',
# Wait for initial sync of all subscriptions
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber1->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
$node_subscriber2->poll_query_until('postgres', $synced_query)
diff --git a/src/test/subscription/t/014_binary.pl b/src/test/subscription/t/014_binary.pl
index 36a2f58e17..d1cc362e3a 100644
--- a/src/test/subscription/t/014_binary.pl
+++ b/src/test/subscription/t/014_binary.pl
@@ -45,7 +45,7 @@ $node_subscriber->safe_psql('postgres',
# Ensure nodes are in sync with each other
$node_publisher->wait_for_catchup('tsub');
$node_subscriber->poll_query_until('postgres',
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');"
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');"
) or die "Timed out while waiting for subscriber to synchronize data";
# Insert some content and make sure it's replicated across
diff --git a/src/test/subscription/t/015_stream.pl b/src/test/subscription/t/015_stream.pl
index 1b0e6fb9fb..9060e2e8f5 100644
--- a/src/test/subscription/t/015_stream.pl
+++ b/src/test/subscription/t/015_stream.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/016_stream_subxact.pl b/src/test/subscription/t/016_stream_subxact.pl
index b6a2d10e91..e9fa91ec2e 100644
--- a/src/test/subscription/t/016_stream_subxact.pl
+++ b/src/test/subscription/t/016_stream_subxact.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/017_stream_ddl.pl b/src/test/subscription/t/017_stream_ddl.pl
index be7d7d74e3..e8da520aa7 100644
--- a/src/test/subscription/t/017_stream_ddl.pl
+++ b/src/test/subscription/t/017_stream_ddl.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/018_stream_subxact_abort.pl b/src/test/subscription/t/018_stream_subxact_abort.pl
index ddf0621558..9a336ec1c8 100644
--- a/src/test/subscription/t/018_stream_subxact_abort.pl
+++ b/src/test/subscription/t/018_stream_subxact_abort.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
index 33e42edfef..a1c1c05785 100644
--- a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
+++ b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
@@ -39,7 +39,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/100_bugs.pl b/src/test/subscription/t/100_bugs.pl
index d1e407aacb..90f8f22cb5 100644
--- a/src/test/subscription/t/100_bugs.pl
+++ b/src/test/subscription/t/100_bugs.pl
@@ -30,7 +30,7 @@ $node_publisher->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int)");
$node_publisher->safe_psql('postgres',
- "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'"
+ "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQLTEST AS 'select x * 2'"
);
# an index with a predicate that lends itself to constant expressions
@@ -43,7 +43,7 @@ $node_subscriber->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int)");
$node_subscriber->safe_psql('postgres',
- "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'"
+ "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQLTEST AS 'select x * 2'"
);
$node_subscriber->safe_psql('postgres',
@@ -145,7 +145,7 @@ $node_twoways->safe_psql(
# XXX maybe this should be integrated in wait_for_catchup() itself.
$node_twoways->wait_for_catchup('testsub');
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_twoways->poll_query_until('d2', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 266098e193..3edf16e25e 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -278,9 +278,9 @@ sub mangle_plpython3
foreach my $test (@$tests)
{
local $/ = undef;
- foreach my $dir ('sql', 'expected')
+ foreach my $dir ('sqltest', 'expected')
{
- my $extension = ($dir eq 'sql' ? 'sql' : 'out');
+ my $extension = ($dir eq 'sqltest' ? 'sqltest' : 'out');
my @files =
glob("$dir/$test.$extension $dir/${test}_[0-9].$extension");
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 943142ced8..332c2620ae 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -747,8 +747,8 @@ FormData_pg_sequence_data
FormData_pg_shdepend
FormData_pg_statistic
FormData_pg_statistic_ext
-FormData_pg_subscription
-FormData_pg_subscription_rel
+FormData_pg_sub
+FormData_pg_sub_rel
FormData_pg_tablespace
FormData_pg_transform
FormData_pg_trigger
@@ -803,8 +803,8 @@ Form_pg_sequence_data
Form_pg_shdepend
Form_pg_statistic
Form_pg_statistic_ext
-Form_pg_subscription
-Form_pg_subscription_rel
+Form_pg_sub
+Form_pg_sub_rel
Form_pg_tablespace
Form_pg_transform
Form_pg_trigger
diff --git a/src/tutorial/funcs.source b/src/tutorial/funcs.source
index 542b5c81ec..2f2c38fac2 100644
--- a/src/tutorial/funcs.source
+++ b/src/tutorial/funcs.source
@@ -22,7 +22,7 @@
-- returns 1
CREATE FUNCTION one() RETURNS integer
- AS 'SELECT 1 as ONE' LANGUAGE SQL;
+ AS 'SELECT 1 as ONE' LANGUAGE SQLTEST;
--
-- functions can be used in any expressions (eg. in the target list or
@@ -35,7 +35,7 @@ SELECT one() AS answer;
-- function returns the sum of its two arguments:
CREATE FUNCTION add_em(integer, integer) RETURNS integer
- AS 'SELECT $1 + $2' LANGUAGE SQL;
+ AS 'SELECT $1 + $2' LANGUAGE SQLTEST;
SELECT add_em(1, 2) AS answer;
@@ -65,7 +65,7 @@ INSERT INTO EMP VALUES ('Ginger', 4800, 30, '(2,4)');
-- double_salary takes a tuple of the EMP table
CREATE FUNCTION double_salary(EMP) RETURNS integer
- AS 'SELECT $1.salary * 2 AS salary' LANGUAGE SQL;
+ AS 'SELECT $1.salary * 2 AS salary' LANGUAGE SQLTEST;
SELECT name, double_salary(EMP) AS dream
FROM EMP
@@ -80,7 +80,7 @@ CREATE FUNCTION new_emp() RETURNS EMP
1000 AS salary,
25 AS age,
''(2,2)''::point AS cubicle'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
-- you can then project a column out of resulting the tuple by using the
-- "function notation" for projection columns. (ie. bar(foo) is equivalent
@@ -91,7 +91,7 @@ SELECT name(new_emp()) AS nobody;
-- let's try one more function that returns tuples
CREATE FUNCTION high_pay() RETURNS setof EMP
AS 'SELECT * FROM EMP where salary > 1500'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT name(high_pay()) AS overpaid;
@@ -109,7 +109,7 @@ SELECT * FROM EMP;
CREATE FUNCTION clean_EMP () RETURNS integer
AS 'DELETE FROM EMP WHERE EMP.salary <= 0;
SELECT 1 AS ignore_this'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT clean_EMP();
On Thu, Jan 21, 2021 at 01:03:58AM +0300, Anastasia Lubennikova wrote:
On 03.01.2021 14:29, Noah Misch wrote:
Overall, this patch predicts a subset of cases where pg_dump will emit a
failing GRANT or REVOKE that targets a pg_catalog object. Can you write a
code comment stating what it does and does not detect? I think it's okay to
not predict every failure, but let's record the intended coverage. Here are a
few examples I know; there may be more. The above query only finds GRANTs to
non-pinned roles. pg_dump dumps the following, but the above query doesn't
find them:REVOKE ALL ON FUNCTION pg_last_wal_replay_lsn FROM public;
GRANT EXECUTE ON FUNCTION pg_reload_conf() TO pg_signal_backend;
I see a new comment listing object types. Please also explain the lack of
preventing REVOKE failures (first example query above) and the limitation
around non-pinned roles (second example).
The above query should test refclassid.
Please do so.
+ /* Handle table column objects */ + if (strstr(aclinfo->obj_type, "column") != NULL) + { + char *name_pos = strstr(aclinfo->obj_ident, + aclinfo->obj_name);
+ if (*name_pos == '\"')
+ name_pos--;
This solves the problem affecting a column named "a.b", but it fails for a
column named "pg_catalog" or "a""b". I recommend solving this by retrieving
all three elements of the pg_identify_object_as_address array, then quoting
each of them on the client side.
On 24.01.2021 11:39, Noah Misch wrote:
On Thu, Jan 21, 2021 at 01:03:58AM +0300, Anastasia Lubennikova wrote:
On 03.01.2021 14:29, Noah Misch wrote:
Overall, this patch predicts a subset of cases where pg_dump will emit a
failing GRANT or REVOKE that targets a pg_catalog object. Can you write a
code comment stating what it does and does not detect? I think it's okay to
not predict every failure, but let's record the intended coverage. Here are a
few examples I know; there may be more. The above query only finds GRANTs to
non-pinned roles. pg_dump dumps the following, but the above query doesn't
find them:REVOKE ALL ON FUNCTION pg_last_wal_replay_lsn FROM public;
GRANT EXECUTE ON FUNCTION pg_reload_conf() TO pg_signal_backend;I see a new comment listing object types. Please also explain the lack of
preventing REVOKE failures (first example query above) and the limitation
around non-pinned roles (second example).
1) Could you please clarify, what do you mean by REVOKE failures?
I tried following example:
Start 9.6 cluster.
REVOKE ALL ON function pg_switch_xlog() FROM public;
REVOKE ALL ON function pg_switch_xlog() FROM backup;
The upgrade to the current master passes with and without patch.
It seems that current implementation of pg_upgrade doesn't take into
account revoke ACLs.
2) As for pinned roles, I think we should fix this behavior, rather than
adding a comment. Because such roles can have grants on system objects.
In earlier versions of the patch, I gathered ACLs directly from system
catalogs: pg_proc.proacl, pg_class.relacl pg_attribute.attacl and
pg_type.typacl.
The only downside of this approach is that it cannot be easily extended
to other object types, as we need to handle every object type separately.
I don't think it is a big deal, as we already do it in
check_for_changed_signatures()
And also the query to gather non-standard ACLs won't look as nice as
now, because of the need to parse arrays of aclitems.
What do you think?
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
On Mon, Jan 25, 2021 at 10:14:43PM +0300, Anastasia Lubennikova wrote:
On 24.01.2021 11:39, Noah Misch wrote:
On Thu, Jan 21, 2021 at 01:03:58AM +0300, Anastasia Lubennikova wrote:
On 03.01.2021 14:29, Noah Misch wrote:
Overall, this patch predicts a subset of cases where pg_dump will emit a
failing GRANT or REVOKE that targets a pg_catalog object. Can you write a
code comment stating what it does and does not detect? I think it's okay to
not predict every failure, but let's record the intended coverage. Here are a
few examples I know; there may be more. The above query only finds GRANTs to
non-pinned roles. pg_dump dumps the following, but the above query doesn't
find them:REVOKE ALL ON FUNCTION pg_last_wal_replay_lsn FROM public;
GRANT EXECUTE ON FUNCTION pg_reload_conf() TO pg_signal_backend;I see a new comment listing object types. Please also explain the lack of
preventing REVOKE failures (first example query above) and the limitation
around non-pinned roles (second example).1) Could you please clarify, what do you mean by REVOKE failures?
I tried following example:
Start 9.6 cluster.
REVOKE ALL ON function pg_switch_xlog() FROM public;
REVOKE ALL ON function pg_switch_xlog() FROM backup;The upgrade to the current master passes with and without patch.
It seems that current implementation of pg_upgrade doesn't take into account
revoke ACLs.
I think you can observe it by adding "revoke all on function
pg_stat_get_subscription from public;" to test_add_acl_to_catalog_objects.sql
and then rerunning your test script. pg_dump will reproduce that REVOKE,
which would fail if postgresql.org had removed that function. That's fine, so
long as a comment mentions the limitation.
2) As for pinned roles, I think we should fix this behavior, rather than
adding a comment. Because such roles can have grants on system objects.In earlier versions of the patch, I gathered ACLs directly from system
catalogs: pg_proc.proacl, pg_class.relacl pg_attribute.attacl and
pg_type.typacl.The only downside of this approach is that it cannot be easily extended to
other object types, as we need to handle every object type separately.
I don't think it is a big deal, as we already do it in
check_for_changed_signatures()And also the query to gather non-standard ACLs won't look as nice as now,
because of the need to parse arrays of aclitems.What do you think?
Hard to say for certain without seeing the code both ways. I'm not generally
enthusiastic about adding pg_upgrade code to predict whether the dump will
fail to restore, because such code will never be as good as just trying the
restore. The patch has 413 lines of code, which is substantial. I would balk
if, for example, the patch tripled in size to catch more cases.
On 27.01.2021 14:21, Noah Misch wrote:
On Mon, Jan 25, 2021 at 10:14:43PM +0300, Anastasia Lubennikova wrote:
1) Could you please clarify, what do you mean by REVOKE failures?
I tried following example:
Start 9.6 cluster.
REVOKE ALL ON function pg_switch_xlog() FROM public;
REVOKE ALL ON function pg_switch_xlog() FROM backup;The upgrade to the current master passes with and without patch.
It seems that current implementation of pg_upgrade doesn't take into account
revoke ACLs.I think you can observe it by adding "revoke all on function
pg_stat_get_subscription from public;" to test_add_acl_to_catalog_objects.sql
and then rerunning your test script. pg_dump will reproduce that REVOKE,
which would fail if postgresql.org had removed that function. That's fine, so
long as a comment mentions the limitation.
In the updated patch, I implemented generation of both GRANT ALL and
REVOKE ALL for problematic objects. If I understand it correctly, these
calls will clean object's ACL completely. And I see no harm in doing
this, because the objects don't exist in the new cluster anyway.
To test it I attempted to reproduce the problem, using attached
test_revoke.sql in the test. Still, pg_upgrade works fine without any
adjustments. I'd be grateful if you test it some more.
2) As for pinned roles, I think we should fix this behavior, rather than
adding a comment. Because such roles can have grants on system objects.In earlier versions of the patch, I gathered ACLs directly from system
catalogs: pg_proc.proacl, pg_class.relacl pg_attribute.attacl and
pg_type.typacl.The only downside of this approach is that it cannot be easily extended to
other object types, as we need to handle every object type separately.
I don't think it is a big deal, as we already do it in
check_for_changed_signatures()And also the query to gather non-standard ACLs won't look as nice as now,
because of the need to parse arrays of aclitems.What do you think?
Hard to say for certain without seeing the code both ways. I'm not generally
enthusiastic about adding pg_upgrade code to predict whether the dump will
fail to restore, because such code will never be as good as just trying the
restore. The patch has 413 lines of code, which is substantial. I would balk
if, for example, the patch tripled in size to catch more cases.
Agree.
I attempted to write alternative version, but it seems too complicated.
So I just added a comment about this limitation.
Quoting of table column GRANT/REVOKE statements is fixed in this version.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v13.patchtext/x-patch; charset=UTF-8; name=pg_upgrade_ACL_check_v13.patchDownload
commit f7e5114d4cc9ac7e92aa66cbdf4c98a5c230323a
Author: anastasia <a.lubennikova@postgrespro.ru>
Date: Wed Jan 27 17:49:37 2021 +0300
v13
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 43fc297eb6..0dcef909b0 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -151,6 +152,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -170,6 +173,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -328,6 +332,242 @@ check_cluster_compatibility(bool live_check)
"the old and new port numbers must be different.\n");
}
+/*
+ * check_for_changed_signatures()
+ *
+ * Check that the old cluster doesn't have non-default ACLs for system
+ * objects, which have different signatures in the new cluster,
+ * because they can cause failure during pg_restore stage of
+ * the upgrade process.
+ *
+ * If such objects exist generate fix_system_objects_ACL.sql script
+ * to adjust ACLs before upgrade.
+ *
+ * Currently supported object types are
+ * - table, view, sequence
+ * - table column, view column
+ * - procedure, function, aggregate
+ * - type, domain.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ char subquery[QUERY_ALLOC];
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 906)
+ return;
+
+ prep_status("Checking for system objects with non-default ACL");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+
+ /*
+ * The old cluster doesn't have system objects with non-default ACL,
+ * so exit quickly.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "fix_system_objects_ACL.sql");
+
+ conn = connectToServer(&new_cluster, "template1");
+
+
+ /* Gather the list of system objects' identities in a new cluster */
+
+ snprintf(subquery, sizeof(subquery),
+ /* Get system relations */
+ "SELECT 'pg_class'::regclass classid, oid objid, 0 objsubid "
+ "FROM pg_catalog.pg_class "
+ "WHERE relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system table columns, view columns */
+ "SELECT 'pg_class'::regclass, att.attrelid, att.attnum "
+ "FROM pg_catalog.pg_class rel "
+ "INNER JOIN pg_catalog.pg_attribute att ON rel.oid = att.attrelid "
+ "WHERE rel.relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system functions and procedures */
+ "SELECT 'pg_proc'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_proc "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system types and domains */
+ "SELECT 'pg_type'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_type "
+ "WHERE typnamespace = 'pg_catalog'::regnamespace "
+ );
+
+ res = executeQueryOrDie(conn,
+ "SELECT ident.type, ident.identity "
+ "FROM (%s) obj, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " obj.classid, obj.objid, obj.objsubid) ident "
+ /*
+ * Don't rely on database collation, since we use strcmp
+ * comparison to find non-default ACLs.
+ */
+ "ORDER BY ident.identity COLLATE \"C\";", subquery);
+
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ /* For every database check system objects with non-default ACL. */
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool report = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(aclinfo->obj_ident,
+ PQgetvalue(res, objnum, i_obj_ident));
+
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ {
+ report = true;
+ break;
+ }
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ objnum++;
+ break;
+ }
+ else
+ objnum++;
+ }
+
+ /* Generate REVOKE statemets for the found objects */
+ if (report)
+ {
+ PQExpBufferData acl_buf;
+
+ found_changed = true;
+ if (script == NULL &&
+ (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %m\n", output_path);
+
+ /* append connect database command */
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+
+ initPQExpBuffer(&acl_buf);
+ /*
+ * To handle both GRANT AND REVOKE ACLs we generate two
+ * statements, which will clean object's ACL. Since the
+ * object do not exist in the new cluster, this action
+ * causes no harm.
+ */
+ appendPQExpBuffer(&acl_buf, " GRANT ALL ");
+ if (strstr(aclinfo->obj_type, "column"))
+ appendPQExpBuffer(&acl_buf, " (%s) ",
+ fmtId(aclinfo->obj_name));
+ appendPQExpBuffer(&acl_buf, " ON");
+ if (!aclinfo->is_relation)
+ appendPQExpBuffer(&acl_buf, " %s ", aclinfo->obj_type);
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ appendPQExpBuffer(&acl_buf, " %s.%s ",
+ fmtId(aclinfo->obj_namespace),
+ fmtId(aclinfo->obj_parent_name));
+ else
+ appendPQExpBuffer(&acl_buf, " %s ",
+ aclinfo->obj_ident);
+ appendPQExpBuffer(&acl_buf, " TO %s ;\n",
+ aclinfo->role_names);
+
+ appendPQExpBuffer(&acl_buf, " REVOKE ALL ");
+ if (strstr(aclinfo->obj_type, "column"))
+ appendPQExpBuffer(&acl_buf, " (%s) ",
+ fmtId(aclinfo->obj_name));
+ appendPQExpBuffer(&acl_buf, " ON");
+ if (!aclinfo->is_relation)
+ appendPQExpBuffer(&acl_buf, " %s ", aclinfo->obj_type);
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ appendPQExpBuffer(&acl_buf, " %s.%s ",
+ fmtId(aclinfo->obj_namespace),
+ fmtId(aclinfo->obj_parent_name));
+ else
+ appendPQExpBuffer(&acl_buf, " %s ",
+ aclinfo->obj_ident);
+ appendPQExpBuffer(&acl_buf, " FROM %s ;\n",
+ aclinfo->role_names);
+
+ fputs(acl_buf.data, script);
+ termPQExpBuffer(&acl_buf);
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* check_locale_and_encoding()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 5d9a26cf82..0c6714e6b7 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,143 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Fill AclInfo array with information about system objects that
+ * have non-default ACL.
+ * Non-default privileges granted to default
+ * roles are not handled here, because such roles are pinned and
+ * dependencies between them and objects are not tracked.
+ *
+ * Currently supported object types are
+ * - table, view, sequence
+ * - table column, view column
+ * - procedure, function, aggregate
+ * - type, domain.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos = NULL;
+ AclInfo *curr = NULL;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_obj_namespace,
+ i_obj_parent_name,
+ i_obj_name,
+ i_rolname,
+ i_is_relation;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get system objects with non-default ACLs.
+ */
+ "SELECT obj.type, obj.identity, "
+ " obj_as_address.object_names[1] as namespace, "
+ " obj_as_address.object_names[2] as parent_name, "
+ " obj_as_address.object_names[array_length(object_names, 1)] "
+ " as name, shd.refobjid::regrole rolename, "
+ " CASE WHEN shd.classid = 'pg_class'::regclass THEN true "
+ " ELSE false "
+ " END is_relation "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj, "
+ " pg_catalog.pg_identify_object_as_address("
+ " shd.classid, shd.objid, shd.objsubid) obj_as_address "
+ /* 'a' is for SHARED_DEPENDENCY_ACL */
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.refclassid = 'pg_authid'::regclass::oid "
+ " AND shd.classid IN ('pg_proc'::regclass, "
+ " 'pg_class'::regclass, 'pg_type'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ * Don't rely on database collation, since we use strcmp
+ * comparison below.
+ */
+ "ORDER BY obj.identity COLLATE \"C\";", dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_obj_namespace = PQfnumber(res, "namespace");
+ i_obj_parent_name = PQfnumber(res, "parent_name");
+ i_obj_name = PQfnumber(res, "name");
+ i_rolname = PQfnumber(res, "rolename");
+ i_is_relation = PQfnumber(res, "is_relation");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBuffer roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+ curr->obj_namespace = pg_strdup(PQgetvalue(res, aclnum,
+ i_obj_namespace));
+ curr->obj_parent_name = pg_strdup(PQgetvalue(res, aclnum,
+ i_obj_parent_name));
+ curr->obj_name = pg_strdup(PQgetvalue(res, aclnum, i_obj_name));
+ curr->is_relation =
+ PQgetvalue(res, aclnum, i_is_relation)[0] == 't';
+
+ roles_buf = createPQExpBuffer();
+ initPQExpBuffer(roles_buf);
+
+ /*
+ * For each object gather string of role names mentioned in ACL
+ * in a format convenient for further use
+ * in GRANT/REVOKE statement.
+ */
+ while (aclnum < PQntuples(res) &&
+ strcmp(curr->obj_ident,
+ PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf->len != 0)
+ appendPQExpBufferChar(roles_buf, ',');
+
+ appendPQExpBufferStr(roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+
+ curr->role_names = pg_strdup(roles_buf->data);
+ destroyPQExpBuffer(roles_buf);
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -384,6 +523,10 @@ get_db_infos(ClusterInfo *cluster)
dbinfos[tupnum].db_ctype = pg_strdup(PQgetvalue(res, tupnum, i_datctype));
snprintf(dbinfos[tupnum].db_tablespace, sizeof(dbinfos[tupnum].db_tablespace), "%s",
PQgetvalue(res, tupnum, i_spclocation));
+
+ /* initialize clean array */
+ dbinfos[tupnum].non_def_acl_arr.nacls = 0;
+ dbinfos[tupnum].non_def_acl_arr.aclinfos = NULL;
}
PQclear(res);
@@ -595,6 +738,9 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+
+ if (&db_arr->dbs[dbnum].non_def_acl_arr.nacls > 0)
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +766,23 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+
+ pg_free(acl_arr->aclinfos);
+ acl_arr->aclinfos = NULL;
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 919a7849fd..32e305ae00 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -147,6 +147,36 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Information about database object needed to check
+ * if its signature has changed between versions.
+ * We need it to generate a statement to adjust privileges
+ * if necessary.
+ */
+typedef struct
+{
+ char *obj_type; /* object type */
+ char *obj_ident; /* complete object identity */
+
+ /* object namespace, parent name (table name for 'column' objects)
+ * and name. Store them separately from identity to simplify
+ * parsing and qouting.
+ */
+ char *obj_namespace;
+ char *obj_parent_name;
+ char *obj_name;
+
+ bool is_relation; /* if the object is relation */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -183,6 +213,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -389,6 +421,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
test_rename_catalog_objects_v13text/plain; charset=UTF-8; name=test_rename_catalog_objects_v13Download
commit 5d58c1372fa737832106919d87f68d7ad793df51
Author: anastasia <a.lubennikova@postgrespro.ru>
Date: Thu Jan 21 17:16:51 2021 +0300
test_rename_catalog_objects_v11
diff --git a/contrib/ptrack b/contrib/ptrack
new file mode 160000
index 0000000000..c6c19ed121
--- /dev/null
+++ b/contrib/ptrack
@@ -0,0 +1 @@
+Subproject commit c6c19ed121019cc7a980229f2da14beb85c4f4a3
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index c85f0ca7b6..dc5ef06b7f 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -40,7 +40,7 @@ OBJS = \
pg_publication.o \
pg_range.o \
pg_shdepend.o \
- pg_subscription.o \
+ pg_sub.o \
pg_type.o \
storage.o \
toasting.o
@@ -67,8 +67,8 @@ CATALOG_HEADERS := \
pg_foreign_table.h pg_policy.h pg_replication_origin.h \
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
- pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
- pg_subscription_rel.h
+ pg_sequence.h pg_publication.h pg_publication_rel.h pg_sub.h \
+ pg_sub_rel.h
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 1a81e768ec..6b5663961d 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -50,7 +50,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
@@ -5248,7 +5248,7 @@ pg_publication_ownercheck(Oid pub_oid, Oid roleid)
* Ownership check for a subscription (specified by OID).
*/
bool
-pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
+pg_sub_ownercheck(Oid sub_oid, Oid roleid)
{
HeapTuple tuple;
Oid ownerId;
@@ -5263,7 +5263,7 @@ pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription with OID %u does not exist", sub_oid)));
- ownerId = ((Form_pg_subscription) GETSTRUCT(tuple))->subowner;
+ ownerId = ((Form_pg_sub) GETSTRUCT(tuple))->subowner;
ReleaseSysCache(tuple);
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index e2ed80a5de..95257d5db7 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -36,7 +36,7 @@
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 2140151a6a..0dcb701a69 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 9abc4a1f55..f03f25bd56 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -56,7 +56,7 @@
#include "catalog/pg_opclass.h"
#include "catalog/pg_partitioned_table.h"
#include "catalog/pg_statistic.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/storage.h"
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 4907855043..aef3bf7f03 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -42,7 +42,7 @@ SET search_path TO information_schema;
/* Expand any 1-D array into a set with integers 1..N */
CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
RETURNS SETOF RECORD
- LANGUAGE sql STRICT IMMUTABLE PARALLEL SAFE
+ LANGUAGE sqltest STRICT IMMUTABLE PARALLEL SAFE
AS 'select $1[s], s - pg_catalog.array_lower($1,1) + 1
from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
pg_catalog.array_upper($1,1),
@@ -51,7 +51,7 @@ CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
/* Given an index's OID and an underlying-table column number, return the
* column's position in the index (NULL if not there) */
CREATE FUNCTION _pg_index_position(oid, smallint) RETURNS int
- LANGUAGE sql STRICT STABLE
+ LANGUAGE sqltest STRICT STABLE
AS $$
SELECT (ss.a).n FROM
(SELECT information_schema._pg_expandarray(indkey) AS a
@@ -60,7 +60,7 @@ SELECT (ss.a).n FROM
$$;
CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -68,7 +68,7 @@ CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
$$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typbasetype ELSE $1.atttypid END$$;
CREATE FUNCTION _pg_truetypmod(pg_attribute, pg_type) RETURNS int4
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -78,7 +78,7 @@ $$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typtypmod ELSE $1.atttypmod END$$;
-- these functions encapsulate knowledge about the encoding of typmod:
CREATE FUNCTION _pg_char_max_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -94,7 +94,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_char_octet_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -110,7 +110,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -131,7 +131,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision_radix(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -143,7 +143,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_scale(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -159,7 +159,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_datetime_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -175,7 +175,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_interval_type(typid oid, mod int4) RETURNS text
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -1477,7 +1477,7 @@ CREATE VIEW routines AS
CAST(null AS cardinal_number) AS maximum_cardinality,
CAST(CASE WHEN p.prokind <> 'p' THEN 0 END AS sql_identifier) AS dtd_identifier,
- CAST(CASE WHEN l.lanname = 'sql' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
+ CAST(CASE WHEN l.lanname = 'sqltest' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
AS routine_body,
CAST(
CASE WHEN pg_has_role(p.proowner, 'USAGE') THEN p.prosrc ELSE null END
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 6d88b690d8..dfd2a4128f 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
@@ -579,10 +579,10 @@ static const ObjectPropertyType ObjectProperty[] =
SubscriptionObjectIndexId,
SUBSCRIPTIONOID,
SUBSCRIPTIONNAME,
- Anum_pg_subscription_oid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_oid,
+ Anum_pg_sub_subname,
InvalidAttrNumber,
- Anum_pg_subscription_subowner,
+ Anum_pg_sub_subowner,
InvalidAttrNumber,
OBJECT_SUBSCRIPTION,
true
@@ -2510,7 +2510,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
strVal((Value *) object));
break;
case OBJECT_SUBSCRIPTION:
- if (!pg_subscription_ownercheck(address.objectId, roleid))
+ if (!pg_sub_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
strVal((Value *) object));
break;
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 90b7a5de29..8e2bd02dcb 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -40,7 +40,7 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_sub.c
similarity index 83%
rename from src/backend/catalog/pg_subscription.c
rename to src/backend/catalog/pg_sub.c
index 44cb285b68..669975641d 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_sub.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
- * pg_subscription.c
+ * pg_sub.c
* replication subscriptions
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * src/backend/catalog/pg_subscription.c
+ * src/backend/catalog/pg_sub.c
*
*-------------------------------------------------------------------------
*/
@@ -20,8 +20,8 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/indexing.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
@@ -43,7 +43,7 @@ GetSubscription(Oid subid, bool missing_ok)
{
HeapTuple tup;
Subscription *sub;
- Form_pg_subscription subform;
+ Form_pg_sub subform;
Datum datum;
bool isnull;
@@ -57,21 +57,21 @@ GetSubscription(Oid subid, bool missing_ok)
elog(ERROR, "cache lookup failed for subscription %u", subid);
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = (Form_pg_sub) GETSTRUCT(tup);
sub = (Subscription *) palloc(sizeof(Subscription));
sub->oid = subid;
sub->dbid = subform->subdbid;
sub->name = pstrdup(NameStr(subform->subname));
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->binary = subform->subbinary;
sub->stream = subform->substream;
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subconninfo,
+ Anum_pg_sub_subconninfo,
&isnull);
Assert(!isnull);
sub->conninfo = TextDatumGetCString(datum);
@@ -79,7 +79,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subslotname,
+ Anum_pg_sub_subslotname,
&isnull);
if (!isnull)
sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));
@@ -89,7 +89,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get synccommit */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subsynccommit,
+ Anum_pg_sub_subsynccommit,
&isnull);
Assert(!isnull);
sub->synccommit = TextDatumGetCString(datum);
@@ -97,7 +97,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get publications */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subpublications,
+ Anum_pg_sub_subpublications,
&isnull);
Assert(!isnull);
sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
@@ -123,7 +123,7 @@ CountDBSubscriptions(Oid dbid)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- Anum_pg_subscription_subdbid,
+ Anum_pg_sub_subdbid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
@@ -165,7 +165,7 @@ get_subscription_oid(const char *subname, bool missing_ok)
{
Oid oid;
- oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(subname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
@@ -185,7 +185,7 @@ get_subscription_name(Oid subid, bool missing_ok)
{
HeapTuple tup;
char *subname;
- Form_pg_subscription subform;
+ Form_pg_sub subform;
tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
@@ -196,7 +196,7 @@ get_subscription_name(Oid subid, bool missing_ok)
return NULL;
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = (Form_pg_sub) GETSTRUCT(tup);
subname = pstrdup(NameStr(subform->subname));
ReleaseSysCache(tup);
@@ -239,8 +239,8 @@ AddSubscriptionRelState(Oid subid, Oid relid, char state,
{
Relation rel;
HeapTuple tup;
- bool nulls[Natts_pg_subscription_rel];
- Datum values[Natts_pg_subscription_rel];
+ bool nulls[Natts_pg_sub_rel];
+ Datum values[Natts_pg_sub_rel];
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
@@ -257,13 +257,13 @@ AddSubscriptionRelState(Oid subid, Oid relid, char state,
/* Form the tuple. */
memset(values, 0, sizeof(values));
memset(nulls, false, sizeof(nulls));
- values[Anum_pg_subscription_rel_srsubid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_rel_srrelid - 1] = ObjectIdGetDatum(relid);
- values[Anum_pg_subscription_rel_srsubstate - 1] = CharGetDatum(state);
+ values[Anum_pg_sub_rel_srsubid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_rel_srrelid - 1] = ObjectIdGetDatum(relid);
+ values[Anum_pg_sub_rel_srsubstate - 1] = CharGetDatum(state);
if (sublsn != InvalidXLogRecPtr)
- values[Anum_pg_subscription_rel_srsublsn - 1] = LSNGetDatum(sublsn);
+ values[Anum_pg_sub_rel_srsublsn - 1] = LSNGetDatum(sublsn);
else
- nulls[Anum_pg_subscription_rel_srsublsn - 1] = true;
+ nulls[Anum_pg_sub_rel_srsublsn - 1] = true;
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -285,9 +285,9 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
{
Relation rel;
HeapTuple tup;
- bool nulls[Natts_pg_subscription_rel];
- Datum values[Natts_pg_subscription_rel];
- bool replaces[Natts_pg_subscription_rel];
+ bool nulls[Natts_pg_sub_rel];
+ Datum values[Natts_pg_sub_rel];
+ bool replaces[Natts_pg_sub_rel];
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
@@ -306,14 +306,14 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
memset(nulls, false, sizeof(nulls));
memset(replaces, false, sizeof(replaces));
- replaces[Anum_pg_subscription_rel_srsubstate - 1] = true;
- values[Anum_pg_subscription_rel_srsubstate - 1] = CharGetDatum(state);
+ replaces[Anum_pg_sub_rel_srsubstate - 1] = true;
+ values[Anum_pg_sub_rel_srsubstate - 1] = CharGetDatum(state);
- replaces[Anum_pg_subscription_rel_srsublsn - 1] = true;
+ replaces[Anum_pg_sub_rel_srsublsn - 1] = true;
if (sublsn != InvalidXLogRecPtr)
- values[Anum_pg_subscription_rel_srsublsn - 1] = LSNGetDatum(sublsn);
+ values[Anum_pg_sub_rel_srsublsn - 1] = LSNGetDatum(sublsn);
else
- nulls[Anum_pg_subscription_rel_srsublsn - 1] = true;
+ nulls[Anum_pg_sub_rel_srsublsn - 1] = true;
tup = heap_modify_tuple(tup, RelationGetDescr(rel), values, nulls,
replaces);
@@ -350,11 +350,11 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
}
/* Get the state. */
- substate = ((Form_pg_subscription_rel) GETSTRUCT(tup))->srsubstate;
+ substate = ((Form_pg_sub_rel) GETSTRUCT(tup))->srsubstate;
/* Get the LSN */
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
- Anum_pg_subscription_rel_srsublsn, &isnull);
+ Anum_pg_sub_rel_srsublsn, &isnull);
if (isnull)
*sublsn = InvalidXLogRecPtr;
else
@@ -384,7 +384,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
if (OidIsValid(subid))
{
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srsubid,
BTEqualStrategyNumber,
F_OIDEQ,
ObjectIdGetDatum(subid));
@@ -393,7 +393,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
if (OidIsValid(relid))
{
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srrelid,
+ Anum_pg_sub_rel_srrelid,
BTEqualStrategyNumber,
F_OIDEQ,
ObjectIdGetDatum(relid));
@@ -429,7 +429,7 @@ GetSubscriptionRelations(Oid subid)
rel = table_open(SubscriptionRelRelationId, AccessShareLock);
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srsubid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(subid));
@@ -438,18 +438,18 @@ GetSubscriptionRelations(Oid subid)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_subscription_rel subrel;
+ Form_pg_sub_rel subrel;
SubscriptionRelState *relstate;
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = (Form_pg_sub_rel) GETSTRUCT(tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
- Anum_pg_subscription_rel_srsublsn, &isnull);
+ Anum_pg_sub_rel_srsublsn, &isnull);
if (isnull)
relstate->lsn = InvalidXLogRecPtr;
else
@@ -483,12 +483,12 @@ GetSubscriptionNotReadyRelations(Oid subid)
rel = table_open(SubscriptionRelRelationId, AccessShareLock);
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srsubid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(subid));
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubstate,
+ Anum_pg_sub_rel_srsubstate,
BTEqualStrategyNumber, F_CHARNE,
CharGetDatum(SUBREL_STATE_READY));
@@ -497,18 +497,18 @@ GetSubscriptionNotReadyRelations(Oid subid)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_subscription_rel subrel;
+ Form_pg_sub_rel subrel;
SubscriptionRelState *relstate;
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = (Form_pg_sub_rel) GETSTRUCT(tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
- Anum_pg_subscription_rel_srsublsn, &isnull);
+ Anum_pg_sub_rel_srsublsn, &isnull);
if (isnull)
relstate->lsn = InvalidXLogRecPtr;
else
diff --git a/src/backend/catalog/sql_features.txt b/src/backend/catalog/sql_features.txt
index caa971c435..59e028e168 100644
--- a/src/backend/catalog/sql_features.txt
+++ b/src/backend/catalog/sql_features.txt
@@ -28,7 +28,7 @@ B124 Routine language Fortran NO
B125 Routine language MUMPS NO
B126 Routine language Pascal NO
B127 Routine language PL/I NO
-B128 Routine language SQL NO
+B128 Routine LANGUAGE SQLTEST NO
B200 Polymorphic table functions NO
B201 More than one PTF generic table parameter NO
B202 PTF Copartitioning NO
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index fa58afd9d7..6eb18cbde2 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -478,7 +478,7 @@ SELECT
l.provider, l.label
FROM
pg_shseclabel l
- JOIN pg_subscription s ON l.classoid = s.tableoid AND l.objoid = s.oid
+ JOIN pg_sub s ON l.classoid = s.tableoid AND l.objoid = s.oid
UNION ALL
SELECT
l.objoid, l.classoid, 0::int4 AS objsubid,
@@ -832,7 +832,7 @@ CREATE VIEW pg_stat_wal_receiver AS
s.received_tli,
s.last_msg_send_time,
s.last_msg_receipt_time,
- s.latest_end_lsn,
+ s.latest_end_location,
s.latest_end_time,
s.slot_name,
s.sender_host,
@@ -841,7 +841,7 @@ CREATE VIEW pg_stat_wal_receiver AS
FROM pg_stat_get_wal_receiver() s
WHERE s.pid IS NOT NULL;
-CREATE VIEW pg_stat_subscription AS
+CREATE VIEW pg_stat_sub AS
SELECT
su.oid AS subid,
su.subname,
@@ -850,10 +850,10 @@ CREATE VIEW pg_stat_subscription AS
st.received_lsn,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_location,
st.latest_end_time
- FROM pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL) st
+ FROM pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL) st
ON (st.subid = su.oid);
CREATE VIEW pg_stat_ssl AS
@@ -1165,10 +1165,10 @@ CREATE VIEW pg_replication_origin_status AS
REVOKE ALL ON pg_replication_origin_status FROM public;
--- All columns of pg_subscription except subconninfo are readable.
-REVOKE ALL ON pg_subscription FROM public;
-GRANT SELECT (subdbid, subname, subowner, subenabled, subbinary, substream, subslotname, subpublications)
- ON pg_subscription TO public;
+-- All columns of pg_sub except subconninfo are readable.
+REVOKE ALL ON pg_sub FROM public;
+GRANT SELECT (subdbid, subname, subowner, subactive, subbinary, substream, subslotname, subpublications)
+ ON pg_sub TO public;
--
@@ -1218,7 +1218,7 @@ FROM pg_catalog.ts_parse(
) AS tt
WHERE tt.tokid = parse.tokid
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE SQLTEST STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(regconfig,text) IS
'debug function for text search configuration';
@@ -1234,7 +1234,7 @@ RETURNS SETOF record AS
$$
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1);
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE SQLTEST STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(text) IS
'debug function for current text search configuration';
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 29249498a9..6f3d7fc23c 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -35,7 +35,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 2b159b60eb..e44c3b7a97 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -38,7 +38,7 @@
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 082f7855b8..8b368baa96 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -23,8 +23,8 @@
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h"
@@ -345,8 +345,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
Relation rel;
ObjectAddress myself;
Oid subid;
- bool nulls[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
Oid owner = GetUserId();
HeapTuple tup;
bool connect;
@@ -407,7 +407,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Check if name is used */
- subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(stmt->subname));
if (OidIsValid(subid))
{
@@ -438,25 +438,25 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
memset(nulls, false, sizeof(nulls));
subid = GetNewOidWithIndex(rel, SubscriptionObjectIndexId,
- Anum_pg_subscription_oid);
- values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
- values[Anum_pg_subscription_subname - 1] =
+ Anum_pg_sub_oid);
+ values[Anum_pg_sub_oid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
+ values[Anum_pg_sub_subname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
- values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
- values[Anum_pg_subscription_subenabled - 1] = BoolGetDatum(enabled);
- values[Anum_pg_subscription_subbinary - 1] = BoolGetDatum(binary);
- values[Anum_pg_subscription_substream - 1] = BoolGetDatum(streaming);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subowner - 1] = ObjectIdGetDatum(owner);
+ values[Anum_pg_sub_subactive - 1] = BoolGetDatum(enabled);
+ values[Anum_pg_sub_subbinary - 1] = BoolGetDatum(binary);
+ values[Anum_pg_sub_substream - 1] = BoolGetDatum(streaming);
+ values[Anum_pg_sub_subconninfo - 1] =
CStringGetTextDatum(conninfo);
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- values[Anum_pg_subscription_subsynccommit - 1] =
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(publications);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -670,14 +670,14 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
{
Relation rel;
ObjectAddress myself;
- bool nulls[Natts_pg_subscription];
- bool replaces[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ bool replaces[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
HeapTuple tup;
Oid subid;
bool update_tuple = false;
Subscription *sub;
- Form_pg_subscription form;
+ Form_pg_sub form;
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
@@ -691,11 +691,11 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
errmsg("subscription \"%s\" does not exist",
stmt->subname)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
subid = form->oid;
/* must be owner */
- if (!pg_subscription_ownercheck(subid, GetUserId()))
+ if (!pg_sub_ownercheck(subid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
stmt->subname);
@@ -741,32 +741,32 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
"slot_name = NONE")));
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- replaces[Anum_pg_subscription_subslotname - 1] = true;
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ replaces[Anum_pg_sub_subslotname - 1] = true;
}
if (synchronous_commit)
{
- values[Anum_pg_subscription_subsynccommit - 1] =
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- replaces[Anum_pg_subscription_subsynccommit - 1] = true;
+ replaces[Anum_pg_sub_subsynccommit - 1] = true;
}
if (binary_given)
{
- values[Anum_pg_subscription_subbinary - 1] =
+ values[Anum_pg_sub_subbinary - 1] =
BoolGetDatum(binary);
- replaces[Anum_pg_subscription_subbinary - 1] = true;
+ replaces[Anum_pg_sub_subbinary - 1] = true;
}
if (streaming_given)
{
- values[Anum_pg_subscription_substream - 1] =
+ values[Anum_pg_sub_substream - 1] =
BoolGetDatum(streaming);
- replaces[Anum_pg_subscription_substream - 1] = true;
+ replaces[Anum_pg_sub_substream - 1] = true;
}
update_tuple = true;
@@ -795,9 +795,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot enable subscription that does not have a slot name")));
- values[Anum_pg_subscription_subenabled - 1] =
+ values[Anum_pg_sub_subactive - 1] =
BoolGetDatum(enabled);
- replaces[Anum_pg_subscription_subenabled - 1] = true;
+ replaces[Anum_pg_sub_subactive - 1] = true;
if (enabled)
ApplyLauncherWakeupAtCommit();
@@ -812,9 +812,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
/* Check the connection info string. */
walrcv_check_conninfo(stmt->conninfo);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subconninfo - 1] =
CStringGetTextDatum(stmt->conninfo);
- replaces[Anum_pg_subscription_subconninfo - 1] = true;
+ replaces[Anum_pg_sub_subconninfo - 1] = true;
update_tuple = true;
break;
@@ -833,9 +833,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
&refresh,
NULL, NULL, /* no "binary" */
NULL, NULL); /* no "streaming" */
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(stmt->publication);
- replaces[Anum_pg_subscription_subpublications - 1] = true;
+ replaces[Anum_pg_sub_subpublications - 1] = true;
update_tuple = true;
@@ -929,10 +929,10 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
RepOriginId originid;
WalReceiverConn *wrconn = NULL;
StringInfoData cmd;
- Form_pg_subscription form;
+ Form_pg_sub form;
/*
- * Lock pg_subscription with AccessExclusiveLock to ensure that the
+ * Lock pg_sub with AccessExclusiveLock to ensure that the
* launcher doesn't restart new worker during dropping the subscription
*/
rel = table_open(SubscriptionRelationId, AccessExclusiveLock);
@@ -957,11 +957,11 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
return;
}
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
subid = form->oid;
/* must be owner */
- if (!pg_subscription_ownercheck(subid, GetUserId()))
+ if (!pg_sub_ownercheck(subid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
stmt->subname);
@@ -976,19 +976,19 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
/* Get subname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subname, &isnull);
+ Anum_pg_sub_subname, &isnull);
Assert(!isnull);
subname = pstrdup(NameStr(*DatumGetName(datum)));
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subconninfo, &isnull);
+ Anum_pg_sub_subconninfo, &isnull);
Assert(!isnull);
conninfo = TextDatumGetCString(datum);
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subslotname, &isnull);
+ Anum_pg_sub_subslotname, &isnull);
if (!isnull)
slotname = pstrdup(NameStr(*DatumGetName(datum)));
else
@@ -1118,14 +1118,14 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
static void
AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
- Form_pg_subscription form;
+ Form_pg_sub form;
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
if (form->subowner == newOwnerId)
return;
- if (!pg_subscription_ownercheck(form->oid, GetUserId()))
+ if (!pg_sub_ownercheck(form->oid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
NameStr(form->subname));
@@ -1159,7 +1159,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
HeapTuple tup;
Relation rel;
ObjectAddress address;
- Form_pg_subscription form;
+ Form_pg_sub form;
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
@@ -1171,7 +1171,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription \"%s\" does not exist", name)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
subid = form->oid;
AlterSubscriptionOwner_internal(rel, tup, newOwnerId);
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 186514cd9e..8dc6e852f9 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -22,8 +22,8 @@
#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "funcapi.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
@@ -95,7 +95,7 @@ static void logicalrep_worker_cleanup(LogicalRepWorker *worker);
static bool on_commit_launcher_wakeup = false;
-Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
+Datum pg_stat_get_sub(PG_FUNCTION_ARGS);
/*
@@ -135,7 +135,7 @@ get_subscription_list(void)
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
- Form_pg_subscription subform = (Form_pg_subscription) GETSTRUCT(tup);
+ Form_pg_sub subform = (Form_pg_sub) GETSTRUCT(tup);
Subscription *sub;
MemoryContext oldcxt;
@@ -151,7 +151,7 @@ get_subscription_list(void)
sub->oid = subform->oid;
sub->dbid = subform->subdbid;
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->name = pstrdup(NameStr(subform->subname));
/* We don't fill fields we are not interested in. */
@@ -927,7 +927,7 @@ AtEOSubXact_ApplyLauncher(bool isCommit, int nestDepth)
*
* This is used to send launcher signal to stop sleeping and process the
* subscriptions when current transaction commits. Should be used when new
- * tuple was added to the pg_subscription catalog.
+ * tuple was added to the pg_sub catalog.
*/
void
ApplyLauncherWakeupAtCommit(void)
@@ -966,7 +966,7 @@ ApplyLauncherMain(Datum main_arg)
/*
* Establish connection to nailed catalogs (we only ever access
- * pg_subscription).
+ * pg_sub).
*/
BackgroundWorkerInitializeConnection(NULL, NULL, 0);
@@ -1072,7 +1072,7 @@ IsLogicalLauncher(void)
* Returns state of the subscriptions.
*/
Datum
-pg_stat_get_subscription(PG_FUNCTION_ARGS)
+pg_stat_get_sub(PG_FUNCTION_ARGS)
{
#define PG_STAT_GET_SUBSCRIPTION_COLS 8
Oid subid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index e861c0ff80..997a535f0f 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -20,7 +20,7 @@
#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/namespace.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub_rel.h"
#include "executor/executor.h"
#include "nodes/makefuncs.h"
#include "replication/logicalrelation.h"
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 863d196fd7..5be56c80a4 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -51,7 +51,7 @@
* So the state progression is always: INIT -> DATASYNC -> SYNCWAIT ->
* CATCHUP -> SYNCDONE -> READY.
*
- * The catalog pg_subscription_rel is used to keep information about
+ * The catalog pg_sub_rel is used to keep information about
* subscribed tables and their state. Some transient state during data
* synchronization is kept in shared memory. The states SYNCWAIT and
* CATCHUP only appear in memory.
@@ -92,7 +92,7 @@
#include "access/table.h"
#include "access/xact.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_type.h"
#include "commands/copy.h"
#include "miscadmin.h"
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index f2b2549a51..76593b878a 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -65,8 +65,8 @@
#include "catalog/namespace.h"
#include "catalog/partition.h"
#include "catalog/pg_inherits.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_tablespace.h"
#include "commands/tablecmds.h"
#include "commands/tablespace.h"
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 723f513d8b..899af845b5 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1311,7 +1311,7 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
TimeLineID received_tli;
TimestampTz last_send_time;
TimestampTz last_receipt_time;
- XLogRecPtr latest_end_lsn;
+ XLogRecPtr latest_end_location;
TimestampTz latest_end_time;
char sender_host[NI_MAXHOST];
int sender_port = 0;
@@ -1330,7 +1330,7 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
received_tli = WalRcv->receivedTLI;
last_send_time = WalRcv->lastMsgSendTime;
last_receipt_time = WalRcv->lastMsgReceiptTime;
- latest_end_lsn = WalRcv->latestWalEnd;
+ latest_end_location = WalRcv->latestWalEnd;
latest_end_time = WalRcv->latestWalEndTime;
strlcpy(slotname, (char *) WalRcv->slotname, sizeof(slotname));
strlcpy(sender_host, (char *) WalRcv->sender_host, sizeof(sender_host));
@@ -1390,10 +1390,10 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
nulls[8] = true;
else
values[8] = TimestampTzGetDatum(last_receipt_time);
- if (XLogRecPtrIsInvalid(latest_end_lsn))
+ if (XLogRecPtrIsInvalid(latest_end_location))
nulls[9] = true;
else
- values[9] = LSNGetDatum(latest_end_lsn);
+ values[9] = LSNGetDatum(latest_end_location);
if (latest_end_time == 0)
nulls[10] = true;
else
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..eb60f2cfb8 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -60,7 +60,7 @@
#include "catalog/pg_rewrite.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
@@ -115,7 +115,7 @@ static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_
static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
-static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_subscription] = {Schema_pg_subscription};
+static const FormData_pg_attribute Desc_pg_sub[Natts_pg_sub] = {Schema_pg_sub};
/*
* Hash tables that index the relation cache
@@ -3845,8 +3845,8 @@ RelationCacheInitializePhase2(void)
Natts_pg_auth_members, Desc_pg_auth_members);
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
Natts_pg_shseclabel, Desc_pg_shseclabel);
- formrdesc("pg_subscription", SubscriptionRelation_Rowtype_Id, true,
- Natts_pg_subscription, Desc_pg_subscription);
+ formrdesc("pg_sub", SubscriptionRelation_Rowtype_Id, true,
+ Natts_pg_sub, Desc_pg_sub);
#define NUM_CRITICAL_SHARED_RELS 5 /* fix if you change list above */
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index e4dc4ee34e..a012f77f9b 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -62,8 +62,8 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
@@ -787,8 +787,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionNameIndexId,
2,
{
- Anum_pg_subscription_subdbid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_subdbid,
+ Anum_pg_sub_subname,
0,
0
},
@@ -798,7 +798,7 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionObjectIndexId,
1,
{
- Anum_pg_subscription_oid,
+ Anum_pg_sub_oid,
0,
0,
0
@@ -809,8 +809,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionRelSrrelidSrsubidIndexId,
2,
{
- Anum_pg_subscription_rel_srrelid,
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srrelid,
+ Anum_pg_sub_rel_srsubid,
0,
0
},
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index 60d306e7c3..00743ead8e 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -46,7 +46,7 @@ static void AddAcl(PQExpBuffer aclbuf, const char *keyword,
* remoteVersion: version of database
*
* Returns true if okay, false if could not parse the acl string.
- * The resulting commands (if any) are appended to the contents of 'sql'.
+ * The resulting commands (if any) are appended to the contents of 'sqltest'.
*
* Note: when processing a default ACL, prefix is "ALTER DEFAULT PRIVILEGES "
* or something similar, and name is an empty string.
@@ -378,7 +378,7 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
* remoteVersion: version of database
*
* Returns true if okay, false if could not parse the acl string.
- * The resulting commands (if any) are appended to the contents of 'sql'.
+ * The resulting commands (if any) are appended to the contents of 'sqltest'.
*/
bool
buildDefaultACLCommands(const char *type, const char *nspname,
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 798d14580e..d0d0ec7077 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4244,7 +4244,7 @@ getSubscriptions(Archive *fout)
int n;
res = ExecuteSqlQuery(fout,
- "SELECT count(*) FROM pg_subscription "
+ "SELECT count(*) FROM pg_sub "
"WHERE subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getSubscriptions(Archive *fout)
appendPQExpBufferStr(query, " false AS substream\n");
appendPQExpBufferStr(query,
- "FROM pg_subscription s\n"
+ "FROM pg_sub s\n"
"WHERE s.subdbid = (SELECT oid FROM pg_database\n"
" WHERE datname = current_database())");
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 2b501166b8..684350a123 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -1867,10 +1867,10 @@ my %tests = (
'CREATE FUNCTION ... SUPPORT' => {
create_order => 41,
create_sql =>
- 'CREATE FUNCTION dump_test.func_with_support() RETURNS int LANGUAGE sql AS $$ SELECT 1 $$ SUPPORT varchar_support;',
+ 'CREATE FUNCTION dump_test.func_with_support() RETURNS int LANGUAGE sqltest AS $$ SELECT 1 $$ SUPPORT varchar_support;',
regexp => qr/^
\QCREATE FUNCTION dump_test.func_with_support() RETURNS integer\E
- \n\s+\QLANGUAGE sql SUPPORT varchar_support\E
+ \n\s+\QLANGUAGE sqltest SUPPORT varchar_support\E
\n\s+AS\ \$\$\Q SELECT 1 \E\$\$;
/xm,
like =>
@@ -1881,10 +1881,10 @@ my %tests = (
'CREATE PROCEDURE dump_test.ptest1' => {
create_order => 41,
create_sql => 'CREATE PROCEDURE dump_test.ptest1(a int)
- LANGUAGE SQL AS $$ INSERT INTO dump_test.test_table (col1) VALUES (a) $$;',
+ LANGUAGE SQLTEST AS $$ INSERT INTO dump_test.test_table (col1) VALUES (a) $$;',
regexp => qr/^
\QCREATE PROCEDURE dump_test.ptest1(a integer)\E
- \n\s+\QLANGUAGE sql\E
+ \n\s+\QLANGUAGE sqltest\E
\n\s+AS\ \$\$\Q INSERT INTO dump_test.test_table (col1) VALUES (a) \E\$\$;
/xm,
like =>
@@ -1987,9 +1987,9 @@ my %tests = (
'CREATE TRANSFORM FOR int' => {
create_order => 34,
create_sql =>
- 'CREATE TRANSFORM FOR int LANGUAGE SQL (FROM SQL WITH FUNCTION prsd_lextype(internal), TO SQL WITH FUNCTION int4recv(internal));',
+ 'CREATE TRANSFORM FOR int LANGUAGE SQLTEST (FROM SQL WITH FUNCTION prsd_lextype(internal), TO SQL WITH FUNCTION int4recv(internal));',
regexp =>
- qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog\.prsd_lextype\(internal\), TO SQL WITH FUNCTION pg_catalog\.int4recv\(internal\)\);/m,
+ qr/CREATE TRANSFORM FOR integer LANGUAGE sqltest \(FROM SQL WITH FUNCTION pg_catalog\.prsd_lextype\(internal\), TO SQL WITH FUNCTION pg_catalog\.int4recv\(internal\)\);/m,
like => { %full_runs, section_pre_data => 1, },
},
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index caf97563f4..fbc85d2341 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -6005,7 +6005,7 @@ describeSubscriptions(const char *pattern, bool verbose)
printfPQExpBuffer(&buf,
"SELECT subname AS \"%s\"\n"
", pg_catalog.pg_get_userbyid(subowner) AS \"%s\"\n"
- ", subenabled AS \"%s\"\n"
+ ", subactive AS \"%s\"\n"
", subpublications AS \"%s\"\n",
gettext_noop("Name"),
gettext_noop("Owner"),
@@ -6031,7 +6031,7 @@ describeSubscriptions(const char *pattern, bool verbose)
/* Only display subscriptions in current database. */
appendPQExpBufferStr(&buf,
- "FROM pg_catalog.pg_subscription\n"
+ "FROM pg_catalog.pg_sub\n"
"WHERE subdbid = (SELECT oid\n"
" FROM pg_catalog.pg_database\n"
" WHERE datname = pg_catalog.current_database())");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 6abcbea963..a94328fbea 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -999,7 +999,7 @@ static const VersionedQuery Query_for_list_of_publications[] = {
static const VersionedQuery Query_for_list_of_subscriptions[] = {
{100000,
" SELECT pg_catalog.quote_ident(s.subname) "
- " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d "
+ " FROM pg_catalog.pg_sub s, pg_catalog.pg_database d "
" WHERE substring(pg_catalog.quote_ident(s.subname),1,%d)='%s' "
" AND d.datname = pg_catalog.current_database() "
" AND s.subdbid = d.oid"
diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl
index 9e36b6d2b0..37bd088e9e 100644
--- a/src/bin/scripts/t/100_vacuumdb.pl
+++ b/src/bin/scripts/t/100_vacuumdb.pl
@@ -88,8 +88,8 @@ $node->safe_psql(
CREATE TABLE vactable (a int, b int);
CREATE VIEW vacview AS SELECT 1 as a;
- CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQL AS 'SELECT $1 * $1';
- CREATE FUNCTION f1(int) RETURNS int LANGUAGE SQL AS 'SELECT f0($1)';
+ CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQLTEST AS 'SELECT $1 * $1';
+ CREATE FUNCTION f1(int) RETURNS int LANGUAGE SQLTEST AS 'SELECT f0($1)';
CREATE TABLE funcidx (x int);
INSERT INTO funcidx VALUES (0),(1),(2),(3);
CREATE INDEX i0 ON funcidx ((f1(x)));
diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h
index f272e2c99f..06c6128183 100644
--- a/src/include/catalog/dependency.h
+++ b/src/include/catalog/dependency.h
@@ -131,7 +131,7 @@ typedef enum ObjectClass
OCLASS_POLICY, /* pg_policy */
OCLASS_PUBLICATION, /* pg_publication */
OCLASS_PUBLICATION_REL, /* pg_publication_rel */
- OCLASS_SUBSCRIPTION, /* pg_subscription */
+ OCLASS_SUBSCRIPTION, /* pg_sub */
OCLASS_TRANSFORM /* pg_transform */
} ObjectClass;
diff --git a/src/include/catalog/pg_language.dat b/src/include/catalog/pg_language.dat
index a584679927..88f710f9f0 100644
--- a/src/include/catalog/pg_language.dat
+++ b/src/include/catalog/pg_language.dat
@@ -20,6 +20,6 @@
lanname => 'c', lanvalidator => 'fmgr_c_validator' },
{ oid => '14', oid_symbol => 'SQLlanguageId',
descr => 'SQL-language functions',
- lanname => 'sql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
+ lanname => 'sqltest', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
]
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index dd64c3bd60..ab9f66e703 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2350,7 +2350,7 @@
proname => 'justify_days', prorettype => 'interval',
proargtypes => 'interval', prosrc => 'interval_justify_days' },
{ oid => '1176', descr => 'convert date and time to timestamp with time zone',
- proname => 'timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'timestamptz', prolang => 'sqltest', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'date time',
prosrc => 'select cast(($1 + $2) as timestamp with time zone)' },
{ oid => '1178', descr => 'convert timestamp with time zone to date',
@@ -2403,16 +2403,16 @@
prosrc => 'interval_scale' },
{ oid => '1215', descr => 'get description for object id and catalog name',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP) and objsubid = 0' },
{ oid => '1216', descr => 'get description for table column',
- proname => 'col_description', prolang => 'sql', procost => '100',
+ proname => 'col_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'pg_catalog.pg_class\'::pg_catalog.regclass and objsubid = $2' },
{ oid => '1993',
descr => 'get description for object id and shared catalog name',
- proname => 'shobj_description', prolang => 'sql', procost => '100',
+ proname => 'shobj_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = PGNSP)' },
@@ -2585,13 +2585,13 @@
prosrc => 'hashtidextended' },
{ oid => '1296',
- proname => 'timedate_pl', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'timedate_pl', prolang => 'sqltest', prorettype => 'timestamp',
proargtypes => 'time date', prosrc => 'select ($2 + $1)' },
{ oid => '1297',
proname => 'datetimetz_pl', prorettype => 'timestamptz',
proargtypes => 'date timetz', prosrc => 'datetimetz_timestamptz' },
{ oid => '1298',
- proname => 'timetzdate_pl', prolang => 'sql', prorettype => 'timestamptz',
+ proname => 'timetzdate_pl', prolang => 'sqltest', prorettype => 'timestamptz',
proargtypes => 'timetz date', prosrc => 'select ($2 + $1)' },
{ oid => '1299', descr => 'current transaction time',
proname => 'now', provolatile => 's', prorettype => 'timestamptz',
@@ -2633,17 +2633,17 @@
proargtypes => 'timestamptz timestamptz timestamptz timestamptz',
prosrc => 'overlaps_timestamp' },
{ oid => '1305', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1306', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz timestamptz timestamptz interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1307', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz timestamptz',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2652,15 +2652,15 @@
proname => 'overlaps', proisstrict => 'f', prorettype => 'bool',
proargtypes => 'time time time time', prosrc => 'overlaps_time' },
{ oid => '1309', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1310', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time time time interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1311', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time time',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2741,7 +2741,7 @@
# This form of obj_description is now deprecated, since it will fail if
# OIDs are not unique across system catalogs. Use the other form instead.
{ oid => '1348', descr => 'deprecated, use two-argument form instead',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and objsubid = 0' },
@@ -2825,7 +2825,7 @@
prosrc => 'textlen' },
{ oid => '1384', descr => 'extract field from date',
- proname => 'date_part', prolang => 'sql', prorettype => 'float8',
+ proname => 'date_part', prolang => 'sqltest', prorettype => 'float8',
proargtypes => 'text date',
prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time zone))' },
{ oid => '1385', descr => 'extract field from time',
@@ -2833,7 +2833,7 @@
prosrc => 'time_part' },
{ oid => '1386',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'sqltest', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp with time zone), $1)' },
@@ -2948,7 +2948,7 @@
proname => 'box_div', prorettype => 'box', proargtypes => 'box point',
prosrc => 'box_div' },
{ oid => '1426',
- proname => 'path_contain_pt', prolang => 'sql', prorettype => 'bool',
+ proname => 'path_contain_pt', prolang => 'sqltest', prorettype => 'bool',
proargtypes => 'path point', prosrc => 'select pg_catalog.on_ppath($2, $1)' },
{ oid => '1428',
proname => 'poly_contain_pt', prorettype => 'bool',
@@ -3208,7 +3208,7 @@
proname => 'center', prorettype => 'point', proargtypes => 'circle',
prosrc => 'circle_center' },
{ oid => '1544', descr => 'convert circle to 12-vertex polygon',
- proname => 'polygon', prolang => 'sql', prorettype => 'polygon',
+ proname => 'polygon', prolang => 'sqltest', prorettype => 'polygon',
proargtypes => 'circle', prosrc => 'select pg_catalog.polygon(12, $1)' },
{ oid => '1545', descr => 'number of points',
proname => 'npoints', prorettype => 'int4', proargtypes => 'path',
@@ -3504,11 +3504,11 @@
proname => 'translate', prorettype => 'text', proargtypes => 'text text text',
prosrc => 'translate' },
{ oid => '879', descr => 'left-pad string to length',
- proname => 'lpad', prolang => 'sql', prorettype => 'text',
+ proname => 'lpad', prolang => 'sqltest', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.lpad($1, $2, \' \')' },
{ oid => '880', descr => 'right-pad string to length',
- proname => 'rpad', prolang => 'sql', prorettype => 'text',
+ proname => 'rpad', prolang => 'sqltest', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.rpad($1, $2, \' \')' },
{ oid => '881', descr => 'trim spaces from left end of string',
@@ -4102,7 +4102,7 @@
proname => 'inetpl', prorettype => 'inet', proargtypes => 'inet int8',
prosrc => 'inetpl' },
{ oid => '2631',
- proname => 'int8pl_inet', prolang => 'sql', prorettype => 'inet',
+ proname => 'int8pl_inet', prolang => 'sqltest', prorettype => 'inet',
proargtypes => 'int8 inet', prosrc => 'select $2 + $1' },
{ oid => '2632',
proname => 'inetmi_int8', prorettype => 'inet', proargtypes => 'inet int8',
@@ -4234,13 +4234,13 @@
proname => 'round', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_round' },
{ oid => '1708', descr => 'value rounded to \'scale\' of zero',
- proname => 'round', prolang => 'sql', prorettype => 'numeric',
+ proname => 'round', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.round($1,0)' },
{ oid => '1709', descr => 'value truncated to \'scale\'',
proname => 'trunc', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_trunc' },
{ oid => '1710', descr => 'value truncated to \'scale\' of zero',
- proname => 'trunc', prolang => 'sql', prorettype => 'numeric',
+ proname => 'trunc', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.trunc($1,0)' },
{ oid => '1711', descr => 'nearest integer >= value',
proname => 'ceil', prorettype => 'numeric', proargtypes => 'numeric',
@@ -4340,10 +4340,10 @@
proname => 'numeric', proleakproof => 't', prorettype => 'numeric',
proargtypes => 'int4', prosrc => 'int4_numeric' },
{ oid => '1741', descr => 'base 10 logarithm',
- proname => 'log', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1481', descr => 'base 10 logarithm',
- proname => 'log10', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log10', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1742', descr => 'convert float4 to numeric',
proname => 'numeric', proleakproof => 't', prorettype => 'numeric',
@@ -4479,7 +4479,7 @@
proname => 'quote_literal', prorettype => 'text', proargtypes => 'text',
prosrc => 'quote_literal' },
{ oid => '1285', descr => 'quote a data value for usage in a querystring',
- proname => 'quote_literal', prolang => 'sql', provolatile => 's',
+ proname => 'quote_literal', prolang => 'sqltest', provolatile => 's',
prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_literal($1::pg_catalog.text)' },
{ oid => '1289',
@@ -4488,7 +4488,7 @@
proargtypes => 'text', prosrc => 'quote_nullable' },
{ oid => '1290',
descr => 'quote a possibly-null data value for usage in a querystring',
- proname => 'quote_nullable', prolang => 'sql', proisstrict => 'f',
+ proname => 'quote_nullable', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_nullable($1::pg_catalog.text)' },
@@ -4527,13 +4527,13 @@
prorettype => 'text', proargtypes => 'text', prosrc => 'text_format_nv' },
{ oid => '1810', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'sqltest', prorettype => 'int4',
proargtypes => 'bytea', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1811', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'sqltest', prorettype => 'int4',
proargtypes => 'text', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1812', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'sqltest', prorettype => 'int4',
proargtypes => 'bit', prosrc => 'select pg_catalog.length($1)' },
# Selectivity estimators for LIKE and related operators
@@ -4852,7 +4852,7 @@
prosrc => 'to_ascii_encname' },
{ oid => '1848',
- proname => 'interval_pl_time', prolang => 'sql', prorettype => 'time',
+ proname => 'interval_pl_time', prolang => 'sqltest', prorettype => 'time',
proargtypes => 'interval time', prosrc => 'select $2 + $1' },
{ oid => '1850',
@@ -5265,7 +5265,7 @@
proparallel => 'r', prorettype => 'record', proargtypes => '',
proallargtypes => '{int4,text,pg_lsn,int4,pg_lsn,pg_lsn,int4,timestamptz,timestamptz,pg_lsn,timestamptz,text,text,int4,text}',
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
- proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
+ proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_location,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
prosrc => 'pg_stat_get_wal_receiver' },
{ oid => '8595', descr => 'statistics: information about replication slots',
proname => 'pg_stat_get_replication_slots', prorows => '10',
@@ -5276,12 +5276,12 @@
proargnames => '{slot_name,spill_txns,spill_count,spill_bytes,stream_txns,stream_count,stream_bytes,stats_reset}',
prosrc => 'pg_stat_get_replication_slots' },
{ oid => '6118', descr => 'statistics: information about subscription',
- proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
+ proname => 'pg_stat_get_sub', proisstrict => 'f', provolatile => 's',
proparallel => 'r', prorettype => 'record', proargtypes => 'oid',
proallargtypes => '{oid,oid,oid,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}',
proargmodes => '{i,o,o,o,o,o,o,o,o}',
- proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}',
- prosrc => 'pg_stat_get_subscription' },
+ proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_location,latest_end_time}',
+ prosrc => 'pg_stat_get_sub' },
{ oid => '2026', descr => 'statistics: current backend PID',
proname => 'pg_backend_pid', provolatile => 's', proparallel => 'r',
prorettype => 'int4', proargtypes => '', prosrc => 'pg_backend_pid' },
@@ -5735,11 +5735,11 @@
proargtypes => 'timetz int4', prosrc => 'timetz_scale' },
{ oid => '2003',
- proname => 'textanycat', prolang => 'sql', provolatile => 's',
+ proname => 'textanycat', prolang => 'sqltest', provolatile => 's',
prorettype => 'text', proargtypes => 'text anynonarray',
prosrc => 'select $1 || $2::pg_catalog.text' },
{ oid => '2004',
- proname => 'anytextcat', prolang => 'sql', provolatile => 's',
+ proname => 'anytextcat', prolang => 'sqltest', provolatile => 's',
prorettype => 'text', proargtypes => 'anynonarray text',
prosrc => 'select $1::pg_catalog.text || $2' },
@@ -5839,15 +5839,15 @@
proargtypes => 'timestamp timestamp timestamp timestamp',
prosrc => 'overlaps_timestamp' },
{ oid => '2042', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '2043', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp timestamp timestamp interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '2044', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp timestamp',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
{ oid => '2045', descr => 'less-equal-greater',
@@ -5913,7 +5913,7 @@
proargtypes => 'timestamp timestamp', prosrc => 'timestamp_age' },
{ oid => '2059',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'sqltest', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamp',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp without time zone), $1)' },
@@ -5934,7 +5934,7 @@
proname => 'substring', prorettype => 'text', proargtypes => 'text text',
prosrc => 'textregexsubstr' },
{ oid => '2074', descr => 'extract text matching SQL regular expression',
- proname => 'substring', prolang => 'sql', prorettype => 'text',
+ proname => 'substring', prolang => 'sqltest', prorettype => 'text',
proargtypes => 'text text text',
prosrc => 'select pg_catalog.substring($1, pg_catalog.similar_to_escape($2, $3))' },
@@ -6282,11 +6282,11 @@
proname => 'pg_sleep', provolatile => 'v', prorettype => 'void',
proargtypes => 'float8', prosrc => 'pg_sleep' },
{ oid => '3935', descr => 'sleep for the specified interval',
- proname => 'pg_sleep_for', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_for', prolang => 'sqltest', provolatile => 'v',
prorettype => 'void', proargtypes => 'interval',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from pg_catalog.clock_timestamp() operator(pg_catalog.+) $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '3936', descr => 'sleep until the specified time',
- proname => 'pg_sleep_until', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_until', prolang => 'sqltest', provolatile => 'v',
prorettype => 'void', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '315', descr => 'Is JIT compilation available in this session?',
@@ -7097,7 +7097,7 @@
proargtypes => 'name', prosrc => 'pg_database_size_name' },
{ oid => '2325',
descr => 'disk space usage for the main fork of the specified table or index',
- proname => 'pg_relation_size', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_relation_size', prolang => 'sqltest', provolatile => 'v',
prorettype => 'int8', proargtypes => 'regclass',
prosrc => 'select pg_catalog.pg_relation_size($1, \'main\')' },
{ oid => '2332',
@@ -7999,21 +7999,21 @@
# formerly-missing interval + datetime operators
{ oid => '2546',
- proname => 'interval_pl_date', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'interval_pl_date', prolang => 'sqltest', prorettype => 'timestamp',
proargtypes => 'interval date', prosrc => 'select $2 + $1' },
{ oid => '2547',
- proname => 'interval_pl_timetz', prolang => 'sql', prorettype => 'timetz',
+ proname => 'interval_pl_timetz', prolang => 'sqltest', prorettype => 'timetz',
proargtypes => 'interval timetz', prosrc => 'select $2 + $1' },
{ oid => '2548',
- proname => 'interval_pl_timestamp', prolang => 'sql',
+ proname => 'interval_pl_timestamp', prolang => 'sqltest',
prorettype => 'timestamp', proargtypes => 'interval timestamp',
prosrc => 'select $2 + $1' },
{ oid => '2549',
- proname => 'interval_pl_timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'interval_pl_timestamptz', prolang => 'sqltest', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'interval timestamptz',
prosrc => 'select $2 + $1' },
{ oid => '2550',
- proname => 'integer_pl_date', prolang => 'sql', prorettype => 'date',
+ proname => 'integer_pl_date', prolang => 'sqltest', prorettype => 'date',
proargtypes => 'int4 date', prosrc => 'select $2 + $1' },
{ oid => '2556', descr => 'get OIDs of databases in a tablespace',
@@ -8405,7 +8405,7 @@
proname => 'xpath', prorettype => '_xml', proargtypes => 'text xml _text',
prosrc => 'xpath' },
{ oid => '2932', descr => 'evaluate XPath expression',
- proname => 'xpath', prolang => 'sql', prorettype => '_xml',
+ proname => 'xpath', prolang => 'sqltest', prorettype => '_xml',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath($1, $2, \'{}\'::pg_catalog.text[])' },
@@ -8418,7 +8418,7 @@
proname => 'xpath_exists', prorettype => 'bool',
proargtypes => 'text xml _text', prosrc => 'xpath_exists' },
{ oid => '3050', descr => 'test XML value against XPath expression',
- proname => 'xpath_exists', prolang => 'sql', prorettype => 'bool',
+ proname => 'xpath_exists', prolang => 'sqltest', prorettype => 'bool',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '3051', descr => 'determine if a string is well formed XML',
@@ -8684,7 +8684,7 @@
proname => 'pg_lsn_pli', prorettype => 'pg_lsn',
proargtypes => 'pg_lsn numeric', prosrc => 'pg_lsn_pli' },
{ oid => '5023',
- proname => 'numeric_pl_pg_lsn', prolang => 'sql', prorettype => 'pg_lsn',
+ proname => 'numeric_pl_pg_lsn', prolang => 'sqltest', prorettype => 'pg_lsn',
proargtypes => 'numeric pg_lsn', prosrc => 'select $2 + $1' },
{ oid => '5024',
proname => 'pg_lsn_mii', prorettype => 'pg_lsn',
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_sub.h
similarity index 77%
rename from src/include/catalog/pg_subscription.h
rename to src/include/catalog/pg_sub.h
index e3618028f7..d8dcc056de 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_sub.h
@@ -1,12 +1,12 @@
/* -------------------------------------------------------------------------
*
- * pg_subscription.h
- * definition of the "subscription" system catalog (pg_subscription)
+ * pg_sub.h
+ * definition of the "subscription" system catalog (pg_sub)
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * src/include/catalog/pg_subscription.h
+ * src/include/catalog/pg_sub.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
@@ -18,13 +18,13 @@
#define PG_SUBSCRIPTION_H
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_d.h"
+#include "catalog/pg_sub_d.h"
#include "nodes/pg_list.h"
/* ----------------
- * pg_subscription definition. cpp turns this into
- * typedef struct FormData_pg_subscription
+ * pg_sub definition. cpp turns this into
+ * typedef struct FormData_pg_sub
* ----------------
*/
@@ -36,7 +36,7 @@
*
* NOTE: When adding a column, also update system_views.sql.
*/
-CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
+CATALOG(pg_sub,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
@@ -45,7 +45,7 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
Oid subowner; /* Owner of the subscription */
- bool subenabled; /* True if the subscription is enabled (the
+ bool subactive; /* True if the subscription is enabled (the
* worker should be running) */
bool subbinary; /* True if the subscription wants the
@@ -66,17 +66,17 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
/* List of publications subscribed to */
text subpublications[1] BKI_FORCE_NOT_NULL;
#endif
-} FormData_pg_subscription;
+} FormData_pg_sub;
-typedef FormData_pg_subscription *Form_pg_subscription;
+typedef FormData_pg_sub *Form_pg_sub;
-DECLARE_TOAST(pg_subscription, 4183, 4184);
+DECLARE_TOAST(pg_sub, 4183, 4184);
#define PgSubscriptionToastTable 4183
#define PgSubscriptionToastIndex 4184
-DECLARE_UNIQUE_INDEX(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_sub_oid_index, 6114, on pg_sub using btree(oid oid_ops));
#define SubscriptionObjectIndexId 6114
-DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
+DECLARE_UNIQUE_INDEX(pg_sub_subname_index, 6115, on pg_sub using btree(subdbid oid_ops, subname name_ops));
#define SubscriptionNameIndexId 6115
typedef struct Subscription
diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_sub_rel.h
similarity index 81%
rename from src/include/catalog/pg_subscription_rel.h
rename to src/include/catalog/pg_sub_rel.h
index 06663b9f16..e76a256889 100644
--- a/src/include/catalog/pg_subscription_rel.h
+++ b/src/include/catalog/pg_sub_rel.h
@@ -1,13 +1,13 @@
/* -------------------------------------------------------------------------
*
- * pg_subscription_rel.h
+ * pg_sub_rel.h
* definition of the system catalog containing the state for each
- * replicated table in each subscription (pg_subscription_rel)
+ * replicated table in each subscription (pg_sub_rel)
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * src/include/catalog/pg_subscription_rel.h
+ * src/include/catalog/pg_sub_rel.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
@@ -20,15 +20,15 @@
#include "access/xlogdefs.h"
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_rel_d.h"
+#include "catalog/pg_sub_rel_d.h"
#include "nodes/pg_list.h"
/* ----------------
- * pg_subscription_rel definition. cpp turns this into
- * typedef struct FormData_pg_subscription_rel
+ * pg_sub_rel definition. cpp turns this into
+ * typedef struct FormData_pg_sub_rel
* ----------------
*/
-CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
+CATALOG(pg_sub_rel,6102,SubscriptionRelRelationId)
{
Oid srsubid; /* Oid of subscription */
Oid srrelid; /* Oid of relation */
@@ -45,11 +45,11 @@ CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
* coordination, or NULL if not
* valid */
#endif
-} FormData_pg_subscription_rel;
+} FormData_pg_sub_rel;
-typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;
+typedef FormData_pg_sub_rel *Form_pg_sub_rel;
-DECLARE_UNIQUE_INDEX(pg_subscription_rel_srrelid_srsubid_index, 6117, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
+DECLARE_UNIQUE_INDEX(pg_sub_rel_srrelid_srsubid_index, 6117, on pg_sub_rel using btree(srrelid oid_ops, srsubid oid_ops));
#define SubscriptionRelSrrelidSrsubidIndexId 6117
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h
index d046022e49..c7aeffb0b2 100644
--- a/src/include/replication/worker_internal.h
+++ b/src/include/replication/worker_internal.h
@@ -15,7 +15,7 @@
#include <signal.h>
#include "access/xlogdefs.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
#include "storage/spin.h"
diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h
index 541a438387..ae07279501 100644
--- a/src/include/utils/acl.h
+++ b/src/include/utils/acl.h
@@ -303,7 +303,7 @@ extern bool pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid);
extern bool pg_event_trigger_ownercheck(Oid et_oid, Oid roleid);
extern bool pg_extension_ownercheck(Oid ext_oid, Oid roleid);
extern bool pg_publication_ownercheck(Oid pub_oid, Oid roleid);
-extern bool pg_subscription_ownercheck(Oid sub_oid, Oid roleid);
+extern bool pg_sub_ownercheck(Oid sub_oid, Oid roleid);
extern bool pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid);
extern bool has_createrole_privilege(Oid roleid);
extern bool has_bypassrls_privilege(Oid roleid);
diff --git a/src/pl/plperl/expected/plperl_trigger.out b/src/pl/plperl/expected/plperl_trigger.out
index d4879e2f03..c370a232d3 100644
--- a/src/pl/plperl/expected/plperl_trigger.out
+++ b/src/pl/plperl/expected/plperl_trigger.out
@@ -355,7 +355,7 @@ create event trigger perl_a_snitch on ddl_command_start
execute procedure perlsnitch();
create event trigger perl_b_snitch on ddl_command_end
execute procedure perlsnitch();
-create or replace function foobar() returns int language sql as $$select 1;$$;
+create or replace function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
NOTICE: perlsnitch: ddl_command_start CREATE FUNCTION
NOTICE: perlsnitch: ddl_command_end CREATE FUNCTION
alter function foobar() cost 77;
diff --git a/src/pl/plperl/sql/plperl_trigger.sql b/src/pl/plperl/sql/plperl_trigger.sql
index 4adddeb80a..c893fe772a 100644
--- a/src/pl/plperl/sql/plperl_trigger.sql
+++ b/src/pl/plperl/sql/plperl_trigger.sql
@@ -232,7 +232,7 @@ create event trigger perl_a_snitch on ddl_command_start
create event trigger perl_b_snitch on ddl_command_end
execute procedure perlsnitch();
-create or replace function foobar() returns int language sql as $$select 1;$$;
+create or replace function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
alter function foobar() cost 77;
drop function foobar();
diff --git a/src/pl/plpgsql/src/expected/plpgsql_simple.out b/src/pl/plpgsql/src/expected/plpgsql_simple.out
index 5a2fefa03e..8fa8893b01 100644
--- a/src/pl/plpgsql/src/expected/plpgsql_simple.out
+++ b/src/pl/plpgsql/src/expected/plpgsql_simple.out
@@ -2,7 +2,7 @@
-- Tests for plpgsql's handling of "simple" expressions
--
-- Check that changes to an inline-able function are handled correctly
-create function simplesql(int) returns int language sql
+create function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1';
create function simplecaller() returns int language plpgsql
as $$
@@ -12,7 +12,7 @@ begin
for n in 1..10 loop
sum := sum + simplesql(n);
if n = 5 then
- create or replace function simplesql(int) returns int language sql
+ create or replace function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1 + 100';
end if;
end loop;
diff --git a/src/pl/plpgsql/src/expected/plpgsql_transaction.out b/src/pl/plpgsql/src/expected/plpgsql_transaction.out
index 5f576231c3..6bba3839f1 100644
--- a/src/pl/plpgsql/src/expected/plpgsql_transaction.out
+++ b/src/pl/plpgsql/src/expected/plpgsql_transaction.out
@@ -491,7 +491,7 @@ CONTEXT: PL/pgSQL function inline_code_block line 3 at EXECUTE
-- snapshot handling test
TRUNCATE test2;
CREATE PROCEDURE transaction_test9()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO test2 VALUES (42);
$$;
diff --git a/src/pl/plpgsql/src/sql/plpgsql_simple.sql b/src/pl/plpgsql/src/sql/plpgsql_simple.sql
index 8a95768073..9dc14b425b 100644
--- a/src/pl/plpgsql/src/sql/plpgsql_simple.sql
+++ b/src/pl/plpgsql/src/sql/plpgsql_simple.sql
@@ -3,7 +3,7 @@
--
-- Check that changes to an inline-able function are handled correctly
-create function simplesql(int) returns int language sql
+create function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1';
create function simplecaller() returns int language plpgsql
@@ -14,7 +14,7 @@ begin
for n in 1..10 loop
sum := sum + simplesql(n);
if n = 5 then
- create or replace function simplesql(int) returns int language sql
+ create or replace function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1 + 100';
end if;
end loop;
diff --git a/src/pl/plpgsql/src/sql/plpgsql_transaction.sql b/src/pl/plpgsql/src/sql/plpgsql_transaction.sql
index 7575655c1a..07a9c7b9d7 100644
--- a/src/pl/plpgsql/src/sql/plpgsql_transaction.sql
+++ b/src/pl/plpgsql/src/sql/plpgsql_transaction.sql
@@ -410,7 +410,7 @@ $$;
TRUNCATE test2;
CREATE PROCEDURE transaction_test9()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO test2 VALUES (42);
$$;
diff --git a/src/pl/tcl/expected/pltcl_setup.out b/src/pl/tcl/expected/pltcl_setup.out
index ed809f02bf..6452cde8b4 100644
--- a/src/pl/tcl/expected/pltcl_setup.out
+++ b/src/pl/tcl/expected/pltcl_setup.out
@@ -139,7 +139,7 @@ create function tclsnitch() returns event_trigger language pltcl as $$
$$;
create event trigger tcl_a_snitch on ddl_command_start execute procedure tclsnitch();
create event trigger tcl_b_snitch on ddl_command_end execute procedure tclsnitch();
-create function foobar() returns int language sql as $$select 1;$$;
+create function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
NOTICE: tclsnitch: ddl_command_start CREATE FUNCTION
NOTICE: tclsnitch: ddl_command_end CREATE FUNCTION
alter function foobar() cost 77;
diff --git a/src/pl/tcl/sql/pltcl_setup.sql b/src/pl/tcl/sql/pltcl_setup.sql
index e9f59989b5..8296e4f6f7 100644
--- a/src/pl/tcl/sql/pltcl_setup.sql
+++ b/src/pl/tcl/sql/pltcl_setup.sql
@@ -156,7 +156,7 @@ $$;
create event trigger tcl_a_snitch on ddl_command_start execute procedure tclsnitch();
create event trigger tcl_b_snitch on ddl_command_end execute procedure tclsnitch();
-create function foobar() returns int language sql as $$select 1;$$;
+create function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
alter function foobar() cost 77;
drop function foobar();
diff --git a/src/test/isolation/specs/deadlock-parallel.spec b/src/test/isolation/specs/deadlock-parallel.spec
index 7ad290c0bd..5ae4082052 100644
--- a/src/test/isolation/specs/deadlock-parallel.spec
+++ b/src/test/isolation/specs/deadlock-parallel.spec
@@ -36,10 +36,10 @@
setup
{
- create function lock_share(int,int) returns int language sql as
+ create function lock_share(int,int) returns int LANGUAGE SQLTEST as
'select pg_advisory_xact_lock_shared($1); select 1;' parallel safe;
- create function lock_excl(int,int) returns int language sql as
+ create function lock_excl(int,int) returns int LANGUAGE SQLTEST as
'select pg_advisory_xact_lock($1); select 1;' parallel safe;
create table bigt as select x from generate_series(1, 10000) x;
diff --git a/src/test/isolation/specs/eval-plan-qual.spec b/src/test/isolation/specs/eval-plan-qual.spec
index 70fa320fc4..c5558284d3 100644
--- a/src/test/isolation/specs/eval-plan-qual.spec
+++ b/src/test/isolation/specs/eval-plan-qual.spec
@@ -9,7 +9,7 @@ setup
CREATE TABLE accounts (accountid text PRIMARY KEY, balance numeric not null);
INSERT INTO accounts VALUES ('checking', 600), ('savings', 600);
- CREATE FUNCTION update_checking(int) RETURNS bool LANGUAGE sql AS $$
+ CREATE FUNCTION update_checking(int) RETURNS bool LANGUAGE sqltest AS $$
UPDATE accounts SET balance = balance + 1 WHERE accountid = 'checking'; SELECT true;$$;
CREATE TABLE accounts_ext (accountid text PRIMARY KEY, balance numeric not null, other text);
diff --git a/src/test/isolation/specs/insert-conflict-specconflict.spec b/src/test/isolation/specs/insert-conflict-specconflict.spec
index 6028397491..4c7dae67e2 100644
--- a/src/test/isolation/specs/insert-conflict-specconflict.spec
+++ b/src/test/isolation/specs/insert-conflict-specconflict.spec
@@ -31,7 +31,7 @@ setup
RETURN $1;
END;$$;
- CREATE OR REPLACE FUNCTION ctoast_large_val() RETURNS TEXT LANGUAGE SQL AS 'select array_agg(md5(g::text))::text from generate_series(1, 256) g';
+ CREATE OR REPLACE FUNCTION ctoast_large_val() RETURNS TEXT LANGUAGE SQLTEST AS 'select array_agg(md5(g::text))::text from generate_series(1, 256) g';
CREATE TABLE upserttest(key text, data text);
diff --git a/src/test/isolation/specs/read-write-unique-3.spec b/src/test/isolation/specs/read-write-unique-3.spec
index 52d287721b..ff8f436df6 100644
--- a/src/test/isolation/specs/read-write-unique-3.spec
+++ b/src/test/isolation/specs/read-write-unique-3.spec
@@ -9,7 +9,7 @@ setup
);
CREATE OR REPLACE FUNCTION insert_unique(k integer, v text) RETURNS void
- LANGUAGE SQL AS $$
+ LANGUAGE SQLTEST AS $$
INSERT INTO test (key, val) SELECT k, v WHERE NOT EXISTS (SELECT key FROM test WHERE key = k);
$$;
}
diff --git a/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out b/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
index b2d898a7d1..816710e58f 100644
--- a/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
+++ b/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
@@ -12,7 +12,7 @@ CREATE USER regress_dummy_seclabel_user2;
CREATE TABLE dummy_seclabel_tbl1 (a int, b text);
CREATE TABLE dummy_seclabel_tbl2 (x int, y text);
CREATE VIEW dummy_seclabel_view1 AS SELECT * FROM dummy_seclabel_tbl2;
-CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ language sql;
+CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ LANGUAGE SQLTEST;
CREATE DOMAIN dummy_seclabel_domain AS text;
ALTER TABLE dummy_seclabel_tbl1 OWNER TO regress_dummy_seclabel_user1;
ALTER TABLE dummy_seclabel_tbl2 OWNER TO regress_dummy_seclabel_user2;
diff --git a/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql b/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
index 8c347b6a68..a7d607b2be 100644
--- a/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
+++ b/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
@@ -17,7 +17,7 @@ CREATE USER regress_dummy_seclabel_user2;
CREATE TABLE dummy_seclabel_tbl1 (a int, b text);
CREATE TABLE dummy_seclabel_tbl2 (x int, y text);
CREATE VIEW dummy_seclabel_view1 AS SELECT * FROM dummy_seclabel_tbl2;
-CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ language sql;
+CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ LANGUAGE SQLTEST;
CREATE DOMAIN dummy_seclabel_domain AS text;
ALTER TABLE dummy_seclabel_tbl1 OWNER TO regress_dummy_seclabel_user1;
diff --git a/src/test/modules/test_ddl_deparse/expected/create_transform.out b/src/test/modules/test_ddl_deparse/expected/create_transform.out
index 5066051fca..a9831f2564 100644
--- a/src/test/modules/test_ddl_deparse/expected/create_transform.out
+++ b/src/test/modules/test_ddl_deparse/expected/create_transform.out
@@ -8,8 +8,8 @@
-- We choose some random built-in functions that have the right signature.
-- This won't actually be used, because the SQL function language
-- doesn't implement transforms (there would be no point).
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
NOTICE: DDL test: type simple, tag CREATE TRANSFORM
-DROP TRANSFORM FOR int LANGUAGE SQL;
+DROP TRANSFORM FOR int LANGUAGE SQLTEST;
diff --git a/src/test/modules/test_ddl_deparse/expected/opfamily.out b/src/test/modules/test_ddl_deparse/expected/opfamily.out
index 14bd6037cd..d9a882112c 100644
--- a/src/test/modules/test_ddl_deparse/expected/opfamily.out
+++ b/src/test/modules/test_ddl_deparse/expected/opfamily.out
@@ -56,7 +56,7 @@ NOTICE: DDL test: type alter operator family, tag ALTER OPERATOR FAMILY
-- copied from alter_table.sql
create type ctype as (f1 int, f2 text);
NOTICE: DDL test: type simple, tag CREATE TYPE
-create function same(ctype, ctype) returns boolean language sql
+create function same(ctype, ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
NOTICE: DDL test: type simple, tag CREATE FUNCTION
create operator =(procedure = same, leftarg = ctype, rightarg = ctype);
diff --git a/src/test/modules/test_ddl_deparse/sql/create_transform.sql b/src/test/modules/test_ddl_deparse/sql/create_transform.sql
index 970d89e03d..715ee2a06c 100644
--- a/src/test/modules/test_ddl_deparse/sql/create_transform.sql
+++ b/src/test/modules/test_ddl_deparse/sql/create_transform.sql
@@ -9,8 +9,8 @@
-- We choose some random built-in functions that have the right signature.
-- This won't actually be used, because the SQL function language
-- doesn't implement transforms (there would be no point).
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
-DROP TRANSFORM FOR int LANGUAGE SQL;
+DROP TRANSFORM FOR int LANGUAGE SQLTEST;
diff --git a/src/test/modules/test_ddl_deparse/sql/opfamily.sql b/src/test/modules/test_ddl_deparse/sql/opfamily.sql
index b2bacbbcbd..f16bc90bec 100644
--- a/src/test/modules/test_ddl_deparse/sql/opfamily.sql
+++ b/src/test/modules/test_ddl_deparse/sql/opfamily.sql
@@ -42,7 +42,7 @@ alter operator family integer_ops using btree add
-- copied from alter_table.sql
create type ctype as (f1 int, f2 text);
-create function same(ctype, ctype) returns boolean language sql
+create function same(ctype, ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
create operator =(procedure = same, leftarg = ctype, rightarg = ctype);
diff --git a/src/test/modules/test_extensions/test_ext8--1.0.sql b/src/test/modules/test_extensions/test_ext8--1.0.sql
index 1561ffefaa..f75112870a 100644
--- a/src/test/modules/test_extensions/test_ext8--1.0.sql
+++ b/src/test/modules/test_extensions/test_ext8--1.0.sql
@@ -13,9 +13,9 @@ create table ext8_table1 (f1 posint);
create temp table ext8_temp_table1 (f1 posint);
create function ext8_even (posint) returns bool as
- 'select ($1 % 2) = 0' language sql;
+ 'select ($1 % 2) = 0' LANGUAGE SQLTEST;
create function pg_temp.ext8_temp_even (posint) returns bool as
- 'select ($1 % 2) = 0' language sql;
+ 'select ($1 % 2) = 0' LANGUAGE SQLTEST;
-- we intentionally don't drop the temp objects before exiting
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl
index 501aff0920..b05b1f25a2 100644
--- a/src/test/modules/test_pg_dump/t/001_base.pl
+++ b/src/test/modules/test_pg_dump/t/001_base.pl
@@ -564,7 +564,7 @@ my %tests = (
'CREATE FUNCTION regress_pg_dump_schema.test_func' => {
regexp => qr/^
\QCREATE FUNCTION regress_pg_dump_schema.test_func() RETURNS integer\E
- \n\s+\QLANGUAGE sql\E
+ \n\s+\QLANGUAGE sqltest\E
\n/xm,
like => { binary_upgrade => 1, },
},
diff --git a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql
index 110f7eef66..9c9f381ca5 100644
--- a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql
+++ b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql
@@ -28,7 +28,7 @@ GRANT SELECT(col1) ON regress_pg_dump_table TO public;
GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role;
REVOKE SELECT(col2) ON regress_pg_dump_table FROM regress_dump_test_role;
-CREATE FUNCTION wgo_then_no_access() RETURNS int LANGUAGE SQL AS 'SELECT 1';
+CREATE FUNCTION wgo_then_no_access() RETURNS int LANGUAGE SQLTEST AS 'SELECT 1';
GRANT ALL ON FUNCTION wgo_then_no_access()
TO pg_signal_backend WITH GRANT OPTION;
@@ -54,7 +54,7 @@ CREATE TYPE regress_pg_dump_schema.test_type AS (col1 int);
GRANT USAGE ON TYPE regress_pg_dump_schema.test_type TO regress_dump_test_role;
CREATE FUNCTION regress_pg_dump_schema.test_func () RETURNS int
-AS 'SELECT 1;' LANGUAGE SQL;
+AS 'SELECT 1;' LANGUAGE SQLTEST;
GRANT EXECUTE ON FUNCTION regress_pg_dump_schema.test_func() TO regress_dump_test_role;
CREATE AGGREGATE regress_pg_dump_schema.test_agg(int2)
diff --git a/src/test/modules/unsafe_tests/expected/rolenames.out b/src/test/modules/unsafe_tests/expected/rolenames.out
index eb608fdc2e..14b0590c74 100644
--- a/src/test/modules/unsafe_tests/expected/rolenames.out
+++ b/src/test/modules/unsafe_tests/expected/rolenames.out
@@ -14,7 +14,7 @@ SELECT r.rolname, v.keyword, r.rolcanlogin, r.rolreplication
AS v(uname, keyword)
ON (r.rolname = v.uname)
ORDER BY 1, 2;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chksetconfig()
RETURNS TABLE (db name, "role" name, rolkeyword text, setconfig text[])
AS $$
@@ -30,7 +30,7 @@ SELECT COALESCE(d.datname, 'ALL'), COALESCE(r.rolname, 'ALL'),
ON (r.rolname = v.uname)
WHERE (r.rolname) IN ('Public', 'current_user', 'regress_testrol1', 'regress_testrol2')
ORDER BY 1, 2, 3;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chkumapping()
RETURNS TABLE (umname name, umserver name, umoptions text[])
AS $$
@@ -39,7 +39,7 @@ SELECT r.rolname, s.srvname, m.umoptions
LEFT JOIN pg_roles r ON (r.oid = m.umuser)
JOIN pg_foreign_server s ON (s.oid = m.umserver)
ORDER BY 2, 1;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
--
-- We test creation and use of these role names to ensure that the server
-- correctly distinguishes role keywords from quoted names that look like
diff --git a/src/test/modules/unsafe_tests/sql/rolenames.sql b/src/test/modules/unsafe_tests/sql/rolenames.sql
index adac36536d..a02fc6ae20 100644
--- a/src/test/modules/unsafe_tests/sql/rolenames.sql
+++ b/src/test/modules/unsafe_tests/sql/rolenames.sql
@@ -14,7 +14,7 @@ SELECT r.rolname, v.keyword, r.rolcanlogin, r.rolreplication
AS v(uname, keyword)
ON (r.rolname = v.uname)
ORDER BY 1, 2;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chksetconfig()
RETURNS TABLE (db name, "role" name, rolkeyword text, setconfig text[])
@@ -31,7 +31,7 @@ SELECT COALESCE(d.datname, 'ALL'), COALESCE(r.rolname, 'ALL'),
ON (r.rolname = v.uname)
WHERE (r.rolname) IN ('Public', 'current_user', 'regress_testrol1', 'regress_testrol2')
ORDER BY 1, 2, 3;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chkumapping()
RETURNS TABLE (umname name, umserver name, umoptions text[])
@@ -41,7 +41,7 @@ SELECT r.rolname, s.srvname, m.umoptions
LEFT JOIN pg_roles r ON (r.oid = m.umuser)
JOIN pg_foreign_server s ON (s.oid = m.umserver)
ORDER BY 2, 1;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
--
-- We test creation and use of these role names to ensure that the server
diff --git a/src/test/regress/expected/alter_generic.out b/src/test/regress/expected/alter_generic.out
index 505eb7ede5..fe47e5c11a 100644
--- a/src/test/regress/expected/alter_generic.out
+++ b/src/test/regress/expected/alter_generic.out
@@ -18,9 +18,9 @@ SET search_path = alt_nsp1, public;
-- Function and Aggregate
--
SET SESSION AUTHORIZATION regress_alter_generic_user1;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 1';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 1';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0
@@ -50,9 +50,9 @@ ERROR: must be member of role "regress_alter_generic_user2"
ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3; -- OK
ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2; -- OK
SET SESSION AUTHORIZATION regress_alter_generic_user2;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 2';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 2';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100
@@ -410,7 +410,7 @@ DROP OPERATOR FAMILY alt_opf11 USING gist;
-- Should fail. btree comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf12 USING btree;
-CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2);
ERROR: btree comparison functions must return integer
DROP OPERATOR FAMILY alt_opf12 USING btree;
@@ -419,7 +419,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf13 USING hash;
-CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4);
ERROR: hash function 1 must return integer
DROP OPERATOR FAMILY alt_opf13 USING hash;
@@ -428,7 +428,7 @@ ROLLBACK;
-- Should fail. btree comparison functions should have two arguments in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf14 USING btree;
-CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4);
ERROR: btree comparison functions must have two arguments
DROP OPERATOR FAMILY alt_opf14 USING btree;
@@ -437,7 +437,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should have one argument in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf15 USING hash;
-CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2);
ERROR: hash function 1 must have one argument
DROP OPERATOR FAMILY alt_opf15 USING hash;
diff --git a/src/test/regress/expected/alter_operator.out b/src/test/regress/expected/alter_operator.out
index 71bd484282..f66351528c 100644
--- a/src/test/regress/expected/alter_operator.out
+++ b/src/test/regress/expected/alter_operator.out
@@ -1,5 +1,5 @@
CREATE FUNCTION alter_op_test_fn(boolean, boolean)
-RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
+RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sqltest IMMUTABLE;
CREATE FUNCTION customcontsel(internal, oid, internal, integer)
RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT;
CREATE OPERATOR === (
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 0ce6ee4622..df6fa3b29b 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2804,7 +2804,7 @@ drop type lockmodes;
--
create function test_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql returns null on null input;
+ LANGUAGE SQLTEST returns null on null input;
select test_strict(NULL);
test_strict
-------------
@@ -2820,7 +2820,7 @@ select test_strict(NULL);
create function non_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql called on null input;
+ LANGUAGE SQLTEST called on null input;
select non_strict(NULL);
non_strict
-------------------
@@ -2841,10 +2841,10 @@ create schema alter1;
create schema alter2;
create table alter1.t1(f1 serial primary key, f2 int check (f2 > 0));
create view alter1.v1 as select * from alter1.t1;
-create function alter1.plus1(int) returns int as 'select $1+1' language sql;
+create function alter1.plus1(int) returns int as 'select $1+1' LANGUAGE SQLTEST;
create domain alter1.posint integer check (value > 0);
create type alter1.ctype as (f1 int, f2 text);
-create function alter1.same(alter1.ctype, alter1.ctype) returns boolean language sql
+create function alter1.same(alter1.ctype, alter1.ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
create operator alter1.=(procedure = alter1.same, leftarg = alter1.ctype, rightarg = alter1.ctype);
create operator class alter1.ctype_hash_ops default for type alter1.ctype using hash as
@@ -4338,7 +4338,7 @@ drop function func_part_attach();
-- test case where the partitioning operator is a SQL function whose
-- evaluation results in the table's relcache being rebuilt partway through
-- the execution of an ATTACH PARTITION command
-create function at_test_sql_partop (int4, int4) returns int language sql
+create function at_test_sql_partop (int4, int4) returns int LANGUAGE SQLTEST
as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$;
create operator class at_test_sql_partop for type int4 using btree as
operator 1 < (int4, int4), operator 2 <= (int4, int4),
diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out
index 8bc7721e7d..110eb283d1 100644
--- a/src/test/regress/expected/arrays.out
+++ b/src/test/regress/expected/arrays.out
@@ -1580,12 +1580,12 @@ drop type comptype;
create or replace function unnest1(anyarray)
returns setof anyelement as $$
select $1[s] from generate_subscripts($1,1) g(s);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create or replace function unnest2(anyarray)
returns setof anyelement as $$
select $1[s1][s2] from generate_subscripts($1,1) g1(s1),
generate_subscripts($1,2) g2(s2);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select * from unnest1(array[1,2,3]);
unnest1
---------
diff --git a/src/test/regress/expected/case.out b/src/test/regress/expected/case.out
index 7fcfe9a7a6..b46fd1d378 100644
--- a/src/test/regress/expected/case.out
+++ b/src/test/regress/expected/case.out
@@ -337,7 +337,7 @@ CREATE DOMAIN foodomain AS text;
CREATE FUNCTION volfoo(text) returns foodomain as
'begin return $1::foodomain; end' language plpgsql volatile;
CREATE FUNCTION inline_eq(foodomain, foodomain) returns boolean as
- 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' language sql;
+ 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' LANGUAGE SQLTEST;
CREATE OPERATOR = (procedure = inline_eq,
leftarg = foodomain, rightarg = foodomain);
SELECT CASE volfoo('bar') WHEN 'foo'::foodomain THEN 'is foo' ELSE 'is not foo' END;
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index bc3752e923..41ea82261d 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -811,9 +811,9 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
AS $$ begin return $1 < $2; end $$;
@@ -935,7 +935,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER
(4 rows)
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
a | dup
---+-----
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index 580b00eea7..fa91f76dc1 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -848,9 +848,9 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
AS $$ begin return $1 < $2; end $$;
@@ -972,7 +972,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER
(4 rows)
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
a | dup
---+-----
diff --git a/src/test/regress/expected/collate.out b/src/test/regress/expected/collate.out
index c42ab8f703..4279c6e9d0 100644
--- a/src/test/regress/expected/collate.out
+++ b/src/test/regress/expected/collate.out
@@ -537,7 +537,7 @@ SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2;
(4 rows)
-- result of a SQL function
-CREATE FUNCTION vc (text) RETURNS text LANGUAGE sql
+CREATE FUNCTION vc (text) RETURNS text LANGUAGE sqltest
AS 'select $1::varchar';
SELECT a, b FROM collate_test1 ORDER BY a, vc(b);
a | b
@@ -568,7 +568,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER
(4 rows)
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
a | dup
---+-----
diff --git a/src/test/regress/expected/create_aggregate.out b/src/test/regress/expected/create_aggregate.out
index dcf6909423..0236cfbed1 100644
--- a/src/test/regress/expected/create_aggregate.out
+++ b/src/test/regress/expected/create_aggregate.out
@@ -38,7 +38,7 @@ COMMENT ON AGGREGATE newcnt (*) IS 'an agg(*) comment';
COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment';
-- multi-argument aggregate
create function sum3(int8,int8,int8) returns int8 as
-'select $1 + $2 + $3' language sql strict immutable;
+'select $1 + $2 + $3' LANGUAGE SQLTEST strict immutable;
create aggregate sum2(int8,int8) (
sfunc = sum3, stype = int8,
initcond = '0'
@@ -47,10 +47,10 @@ create aggregate sum2(int8,int8) (
create type aggtype as (a integer, b integer, c text);
create function aggf_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql strict immutable;
+LANGUAGE SQLTEST strict immutable;
create function aggfns_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql immutable;
+LANGUAGE SQLTEST immutable;
create aggregate aggfstr(integer,integer,text) (
sfunc = aggf_trans, stype = aggtype[],
initcond = '{}'
@@ -60,7 +60,7 @@ create aggregate aggfns(integer,integer,text) (
initcond = '{}'
);
-- check error cases that would require run-time type coercion
-create function least_accum(int8, int8) returns int8 language sql as
+create function least_accum(int8, int8) returns int8 LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
stype = int8, sfunc = least_accum
@@ -68,7 +68,7 @@ create aggregate least_agg(int4) (
ERROR: function least_accum(bigint, bigint) requires run-time type coercion
drop function least_accum(int8, int8);
create function least_accum(anycompatible, anycompatible)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
stype = int8, sfunc = least_accum
@@ -81,13 +81,13 @@ drop function least_accum(anycompatible, anycompatible) cascade;
NOTICE: drop cascades to function least_agg(bigint)
-- variadic aggregates
create function least_accum(anyelement, variadic anyarray)
-returns anyelement language sql as
+returns anyelement LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate least_agg(variadic items anyarray) (
stype = anyelement, sfunc = least_accum
);
create function cleast_accum(anycompatible, variadic anycompatiblearray)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate cleast_agg(variadic items anycompatiblearray) (
stype = anycompatible, sfunc = cleast_accum
@@ -248,7 +248,7 @@ ERROR: cannot change routine kind
DETAIL: "myavg" is an ordinary aggregate function.
-- can't change plain function to aggregate:
create function sum4(int8,int8,int8,int8) returns int8 as
-'select $1 + $2 + $3 + $4' language sql strict immutable;
+'select $1 + $2 + $3 + $4' LANGUAGE SQLTEST strict immutable;
CREATE OR REPLACE AGGREGATE sum3 (int8,int8,int8)
(
stype = int8,
@@ -269,7 +269,7 @@ ERROR: parameter "parallel" must be SAFE, RESTRICTED, or UNSAFE
-- invalid: nonstrict inverse with strict forward function
CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS
$$ SELECT $1 - $2; $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE invalidsumdouble (float8)
(
stype = float8,
@@ -282,7 +282,7 @@ ERROR: strictness of aggregate's forward and inverse transition functions must
-- invalid: non-matching result types
CREATE FUNCTION float8mi_int(float8, float8) RETURNS int AS
$$ SELECT CAST($1 - $2 AS INT); $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE wrongreturntype (float8)
(
stype = float8,
diff --git a/src/test/regress/expected/create_cast.out b/src/test/regress/expected/create_cast.out
index 88f94a63b4..cebb491053 100644
--- a/src/test/regress/expected/create_cast.out
+++ b/src/test/regress/expected/create_cast.out
@@ -20,7 +20,7 @@ CREATE TYPE casttesttype (
alignment = int4
);
-- a dummy function to test with
-CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQL AS
+CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQLTEST AS
$$ SELECT 1; $$;
SELECT casttestfunc('foo'::text); -- fails, as there's no cast
ERROR: function casttestfunc(text) does not exist
@@ -63,7 +63,7 @@ SELECT 1234::int4::casttesttype; -- Should work now
DROP CAST (int4 AS casttesttype);
-- Try cast with a function
-CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQL AS
+CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQLTEST AS
$$ SELECT ('foo'::text || $1::text)::casttesttype; $$;
CREATE CAST (int4 AS casttesttype) WITH FUNCTION int4_casttesttype(int4) AS IMPLICIT;
SELECT 1234::int4::casttesttype; -- Should work now
diff --git a/src/test/regress/expected/create_function_3.out b/src/test/regress/expected/create_function_3.out
index ce508ae1dc..6a25967db2 100644
--- a/src/test/regress/expected/create_function_3.out
+++ b/src/test/regress/expected/create_function_3.out
@@ -14,11 +14,11 @@ SET search_path TO temp_func_test, public;
--
-- ARGUMENT and RETURN TYPES
--
-CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
-CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
+CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sqltest'
AS 'SELECT $1[1]::int';
-CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT false';
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
WHERE oid in ('functest_A_1'::regproc,
@@ -52,13 +52,13 @@ SELECT functest_A_3();
--
-- IMMUTABLE | STABLE | VOLATILE
--
-CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sqltest'
STABLE AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sqltest'
VOLATILE AS 'SELECT $1 < 0';
SELECT proname, provolatile FROM pg_proc
WHERE oid in ('functest_B_1'::regproc,
@@ -91,11 +91,11 @@ SELECT proname, provolatile FROM pg_proc
--
-- SECURITY DEFINER | INVOKER
--
-CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY DEFINER AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY INVOKER AS 'SELECT $1 < 0';
SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functest_C_1'::regproc,
@@ -125,9 +125,9 @@ SELECT proname, prosecdef FROM pg_proc
--
-- LEAKPROOF
--
-CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 100';
-CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 > 100';
SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functest_E_1'::regproc,
@@ -167,20 +167,20 @@ SET search_path TO temp_func_test, public;
ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF;
ALTER FUNCTION functest_E_2(int) LEAKPROOF;
ERROR: only superuser can define a leakproof function
-CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 < 200'; -- fail
ERROR: only superuser can define a leakproof function
RESET SESSION AUTHORIZATION;
--
-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
--
-CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 50';
-CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sqltest'
CALLED ON NULL INPUT AS 'SELECT $1 = 50';
-CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sqltest'
RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50';
-CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sqltest'
STRICT AS 'SELECT $1 = 50';
SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functest_F_1'::regproc,
@@ -217,7 +217,7 @@ SELECT pg_get_functiondef('functest_A_1'::regproc);
--------------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_a_1(text, date)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
AS $function$SELECT $1 = 'abcd' AND $2 > '2001-01-01'$function$ +
(1 row)
@@ -227,7 +227,7 @@ SELECT pg_get_functiondef('functest_B_3'::regproc);
-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_b_3(integer)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
STABLE +
AS $function$SELECT $1 = 0$function$ +
@@ -238,7 +238,7 @@ SELECT pg_get_functiondef('functest_C_3'::regproc);
-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_c_3(integer)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
SECURITY DEFINER +
AS $function$SELECT $1 < 0$function$ +
@@ -249,7 +249,7 @@ SELECT pg_get_functiondef('functest_F_2'::regproc);
-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_f_2(integer)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
STRICT +
AS $function$SELECT $1 = 50$function$ +
@@ -258,15 +258,15 @@ SELECT pg_get_functiondef('functest_F_2'::regproc);
-- information_schema tests
CREATE FUNCTION functest_IS_1(a int, b int default 1, c text default 'foo')
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1 + $2';
CREATE FUNCTION functest_IS_2(out a int, b int default 1)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
CREATE FUNCTION functest_IS_3(a int default 1, out b int)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
SELECT routine_name, ordinal_position, parameter_name, parameter_default
FROM information_schema.parameters JOIN information_schema.routines USING (specific_schema, specific_name)
@@ -285,7 +285,7 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
-- overload
-CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
DROP FUNCTION functest_b_1;
DROP FUNCTION functest_b_1; -- error, not found
@@ -294,16 +294,16 @@ DROP FUNCTION functest_b_2; -- error, ambiguous
ERROR: function name "functest_b_2" is not unique
HINT: Specify the argument list to select the function unambiguously.
-- CREATE OR REPLACE tests
-CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL AS 'SELECT $1';
-CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL WINDOW AS 'SELECT $1';
+CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST AS 'SELECT $1';
+CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST WINDOW AS 'SELECT $1';
ERROR: cannot change routine kind
DETAIL: "functest1" is a function.
-CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQL AS 'SELECT $1';
+CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQLTEST AS 'SELECT $1';
ERROR: cannot change routine kind
DETAIL: "functest1" is a function.
DROP FUNCTION functest1(a int);
-- Check behavior of VOID-returning SQL functions
-CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT a + 1 $$;
SELECT voidtest1(42);
voidtest1
@@ -311,7 +311,7 @@ SELECT voidtest1(42);
(1 row)
-CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT voidtest1(a + b) $$;
SELECT voidtest2(11,22);
voidtest2
@@ -328,7 +328,7 @@ EXPLAIN (verbose, costs off) SELECT voidtest2(11,22);
(2 rows)
CREATE TEMP TABLE sometable(f1 int);
-CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a + 1) $$;
SELECT voidtest3(17);
voidtest3
@@ -336,7 +336,7 @@ SELECT voidtest3(17);
(1 row)
-CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a - 1) RETURNING f1 $$;
SELECT voidtest4(39);
voidtest4
@@ -351,7 +351,7 @@ TABLE sometable;
38
(2 rows)
-CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQLTEST AS
$$ SELECT generate_series(1, a) $$ STABLE;
SELECT * FROM voidtest5(3);
voidtest5
diff --git a/src/test/regress/expected/create_operator.out b/src/test/regress/expected/create_operator.out
index 5303277591..93aa09a3e2 100644
--- a/src/test/regress/expected/create_operator.out
+++ b/src/test/regress/expected/create_operator.out
@@ -167,7 +167,7 @@ BEGIN TRANSACTION;
CREATE OR REPLACE FUNCTION fn_op2(boolean, boolean)
RETURNS boolean AS $$
SELECT NULL::BOOLEAN;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
CREATE OPERATOR === (
LEFTARG = boolean,
RIGHTARG = boolean,
@@ -203,7 +203,7 @@ CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op3(type_op3, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op3 FROM regress_rol_op3;
REVOKE USAGE ON TYPE type_op3 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op3;
@@ -221,7 +221,7 @@ CREATE TYPE type_op4 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op4(int8, type_op4)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op4 FROM regress_rol_op4;
REVOKE USAGE ON TYPE type_op4 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op4;
@@ -239,7 +239,7 @@ CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op5(int8, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM PUBLIC;-- Need to do this so that regress_rol_op3 is not allowed EXECUTE via PUBLIC
SET ROLE regress_rol_op5;
@@ -257,7 +257,7 @@ CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op6(int8, int8)
RETURNS type_op6 AS $$
SELECT NULL::type_op6;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op6 FROM regress_rol_op6;
REVOKE USAGE ON TYPE type_op6 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op6;
diff --git a/src/test/regress/expected/create_procedure.out b/src/test/regress/expected/create_procedure.out
index 3838fa2324..82af83c4d2 100644
--- a/src/test/regress/expected/create_procedure.out
+++ b/src/test/regress/expected/create_procedure.out
@@ -8,10 +8,10 @@ ERROR: random() is not a procedure
LINE 1: CALL random();
^
HINT: To call a function, use SELECT.
-CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQL AS $$ SELECT a $$;
+CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQLTEST AS $$ SELECT a $$;
CREATE TABLE cp_test (a int, b text);
CREATE PROCEDURE ptest1(x text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, x);
$$;
@@ -26,7 +26,7 @@ SELECT pg_get_functiondef('ptest1'::regproc);
pg_get_functiondef
---------------------------------------------------
CREATE OR REPLACE PROCEDURE public.ptest1(x text)+
- LANGUAGE sql +
+ LANGUAGE sqltest +
AS $procedure$ +
INSERT INTO cp_test VALUES (1, x); +
$procedure$ +
@@ -66,7 +66,7 @@ SELECT * FROM cp_test ORDER BY b COLLATE "C";
(3 rows)
CREATE PROCEDURE ptest2()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 5;
$$;
@@ -74,7 +74,7 @@ CALL ptest2();
-- nested CALL
TRUNCATE cp_test;
CREATE PROCEDURE ptest3(y text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest1(y);
CALL ptest1($1);
@@ -89,7 +89,7 @@ SELECT * FROM cp_test;
-- output arguments
CREATE PROCEDURE ptest4a(INOUT a int, INOUT b int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 1, 2;
$$;
@@ -100,7 +100,7 @@ CALL ptest4a(NULL, NULL);
(1 row)
CREATE PROCEDURE ptest4b(INOUT b int, INOUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest4a(a, b); -- error, not supported
$$;
@@ -109,7 +109,7 @@ CONTEXT: SQL function "ptest4b"
DROP PROCEDURE ptest4a;
-- named and default parameters
CREATE OR REPLACE PROCEDURE ptest5(a int, b text, c int default 100)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES(a, b);
INSERT INTO cp_test VALUES(c, b);
@@ -134,21 +134,21 @@ SELECT * FROM cp_test;
-- polymorphic types
CREATE PROCEDURE ptest6(a int, b anyelement)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT NULL::int;
$$;
CALL ptest6(1, 2);
-- collation assignment
CREATE PROCEDURE ptest7(a text, b text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT a = b;
$$;
CALL ptest7(least('a', 'b'), 'a');
-- OUT parameters
CREATE PROCEDURE ptest9(OUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, 'a');
SELECT 1;
@@ -170,13 +170,13 @@ ERROR: sum(integer) is not a procedure
LINE 1: CALL sum(1);
^
HINT: To call a function, use SELECT.
-CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
ERROR: invalid attribute in procedure definition
-LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT I...
+LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQLTEST WINDOW AS $$ INSERT I...
^
-CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
ERROR: invalid attribute in procedure definition
-LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT I...
+LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQLTEST STRICT AS $$ INSERT I...
^
ALTER PROCEDURE ptest1(text) STRICT;
ERROR: invalid attribute in procedure definition
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index ed8c01b8de..65aee00962 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -367,7 +367,7 @@ ERROR: exclusion constraints are not supported on partitioned tables
LINE 3: EXCLUDE USING gist (a WITH &&)
^
-- prevent using prohibited expressions in the key
-CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (retset(a));
@@ -390,7 +390,7 @@ CREATE TABLE partitioned (
a int
) PARTITION BY RANGE ((42));
ERROR: cannot use constant expression as partition key
-CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (const_func());
@@ -427,7 +427,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a, ('unknown'));
ERROR: partition key column 2 has pseudo-type unknown
-- functions in key must be immutable
-CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL;
+CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (immut_func(a));
@@ -459,7 +459,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a);
ERROR: cannot add NO INHERIT constraint to partitioned table "partitioned"
-- some checks after successful creation of a partitioned table
-CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL;
+CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int,
b int,
@@ -1149,7 +1149,7 @@ Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS N
DROP TABLE range_parted4;
-- user-defined operator class in partition key
-CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql
+CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sqltest
AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$;
CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS
OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4),
diff --git a/src/test/regress/expected/create_type.out b/src/test/regress/expected/create_type.out
index 14394cc95c..3f4f6ee65f 100644
--- a/src/test/regress/expected/create_type.out
+++ b/src/test/regress/expected/create_type.out
@@ -131,7 +131,7 @@ HINT: Create the type as a shell type, then create its I/O functions, then do a
CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42);
CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS '
SELECT * FROM default_test;
-' LANGUAGE SQL;
+' LANGUAGE SQLTEST;
SELECT * FROM get_default_test();
f1 | f2
-------+----
diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out
index 411d5c003e..fc56c69d8b 100644
--- a/src/test/regress/expected/domain.out
+++ b/src/test/regress/expected/domain.out
@@ -1067,7 +1067,7 @@ drop domain di;
-- this has caused issues in the past
--
create function sql_is_distinct_from(anyelement, anyelement)
-returns boolean language sql
+returns boolean LANGUAGE SQLTEST
as 'select $1 is distinct from $2 limit 1';
create domain inotnull int
check (sql_is_distinct_from(value, null));
diff --git a/src/test/regress/expected/drop_if_exists.out b/src/test/regress/expected/drop_if_exists.out
index 5e44c2c3ce..e4b45fe0df 100644
--- a/src/test/regress/expected/drop_if_exists.out
+++ b/src/test/regress/expected/drop_if_exists.out
@@ -303,8 +303,8 @@ DROP VIEW IF EXISTS no_such_schema.foo;
NOTICE: schema "no_such_schema" does not exist, skipping
-- Check we receive an ambiguous function error when there are
-- multiple matching functions.
-CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ language sql;
-CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ language sql;
+CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ LANGUAGE SQLTEST;
+CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ LANGUAGE SQLTEST;
DROP FUNCTION test_ambiguous_funcname;
ERROR: function name "test_ambiguous_funcname" is not unique
HINT: Specify the argument list to select the function unambiguously.
diff --git a/src/test/regress/expected/event_trigger.out b/src/test/regress/expected/event_trigger.out
index bdd0ffcdaf..9bcb2a56ab 100644
--- a/src/test/regress/expected/event_trigger.out
+++ b/src/test/regress/expected/event_trigger.out
@@ -20,7 +20,7 @@ ERROR: event trigger functions cannot have declared arguments
CONTEXT: compilation of PL/pgSQL function "test_event_trigger_arg" near line 1
-- should fail, SQL functions cannot be event triggers
create function test_event_trigger_sql() returns event_trigger as $$
-SELECT 1 $$ language sql;
+SELECT 1 $$ LANGUAGE SQLTEST;
ERROR: SQL functions cannot return type event_trigger
-- should fail, no elephant_bootstrap entry point
create event trigger regress_event_trigger on elephant_bootstrap
diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out
index b9e25820bc..d3e4a45b7f 100644
--- a/src/test/regress/expected/foreign_data.out
+++ b/src/test/regress/expected/foreign_data.out
@@ -90,7 +90,7 @@ CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator;
(3 rows)
-- HANDLER related checks
-CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;';
+CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQLTEST AS 'SELECT 1;';
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler; -- ERROR
ERROR: function invalid_fdw_handler must return type fdw_handler
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR
diff --git a/src/test/regress/expected/generated.out b/src/test/regress/expected/generated.out
index ca721d38bf..ad1f9c2f11 100644
--- a/src/test/regress/expected/generated.out
+++ b/src/test/regress/expected/generated.out
@@ -463,7 +463,7 @@ CREATE USER regress_user11;
CREATE TABLE gtest11s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (b * 2) STORED);
INSERT INTO gtest11s VALUES (1, 10), (2, 20);
GRANT SELECT (a, c) ON gtest11s TO regress_user11;
-CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQL;
+CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQLTEST;
REVOKE ALL ON FUNCTION gf1(int) FROM PUBLIC;
CREATE TABLE gtest12s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (gf1(b)) STORED);
INSERT INTO gtest12s VALUES (1, 10), (2, 20);
diff --git a/src/test/regress/expected/guc.out b/src/test/regress/expected/guc.out
index 811f80a097..7dfefc246c 100644
--- a/src/test/regress/expected/guc.out
+++ b/src/test/regress/expected/guc.out
@@ -641,7 +641,7 @@ reset search_path;
--
set work_mem = '3MB';
create function report_guc(text) returns text as
-$$ select current_setting($1) $$ language sql
+$$ select current_setting($1) $$ LANGUAGE SQLTEST
set work_mem = '1MB';
select report_guc('work_mem'), current_setting('work_mem');
report_guc | current_setting
@@ -760,13 +760,13 @@ select current_setting('nosuch.setting', true);
-- function SET options; but not if check_function_bodies is off,
-- because that creates ordering hazards for pg_dump
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
NOTICE: text search configuration "no_such_config" does not exist
ERROR: invalid value for parameter "default_text_search_config": "no_such_config"
set check_function_bodies = off;
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
NOTICE: text search configuration "no_such_config" does not exist
select func_with_bad_set();
diff --git a/src/test/regress/expected/infinite_recurse.out b/src/test/regress/expected/infinite_recurse.out
index aa102fadd8..0f4894b057 100644
--- a/src/test/regress/expected/infinite_recurse.out
+++ b/src/test/regress/expected/infinite_recurse.out
@@ -1,7 +1,7 @@
-- Check that stack depth detection mechanism works and
-- max_stack_depth is not set too high.
create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
+'select infinite_recurse()' LANGUAGE SQLTEST;
-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
-- signal handling that would cause this test to crash if it happened
-- to receive an sinval catchup interrupt while the stack is deep:
diff --git a/src/test/regress/expected/infinite_recurse_1.out b/src/test/regress/expected/infinite_recurse_1.out
index b2c99a0d0d..1c27271a46 100644
--- a/src/test/regress/expected/infinite_recurse_1.out
+++ b/src/test/regress/expected/infinite_recurse_1.out
@@ -1,7 +1,7 @@
-- Check that stack depth detection mechanism works and
-- max_stack_depth is not set too high.
create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
+'select infinite_recurse()' LANGUAGE SQLTEST;
-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
-- signal handling that would cause this test to crash if it happened
-- to receive an sinval catchup interrupt while the stack is deep:
diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out
index 2b68aef654..677e3c9bf8 100644
--- a/src/test/regress/expected/inherit.out
+++ b/src/test/regress/expected/inherit.out
@@ -810,7 +810,7 @@ drop table derived;
drop table base;
create table p1(ff1 int);
create table p2(f1 text);
-create function p2text(p2) returns text as 'select $1.f1' language sql;
+create function p2text(p2) returns text as 'select $1.f1' LANGUAGE SQLTEST;
create table c1(f3 int) inherits(p1,p2);
insert into c1 values(123456789, 'hi', 42);
select p2text(c1.*) from c1;
diff --git a/src/test/regress/expected/insert.out b/src/test/regress/expected/insert.out
index da50ee3b67..fdd7881335 100644
--- a/src/test/regress/expected/insert.out
+++ b/src/test/regress/expected/insert.out
@@ -394,7 +394,7 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
create or replace function part_hashint4_noop(value int4, seed int8)
returns int8 as $$
select value + seed;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_int4_ops
for type int4
using hash as
@@ -403,7 +403,7 @@ function 2 part_hashint4_noop(int4, int8);
create or replace function part_hashtext_length(value text, seed int8)
RETURNS int8 AS $$
select length(coalesce(value, ''))::int8
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_text_ops
for type text
using hash as
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index 81b42c601b..02aef01ce6 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -3494,9 +3494,9 @@ where nt3.id = 1 and ss2.b3;
drop function f_immutable_int4(int);
-- test inlining when function returns composite
create function mki8(bigint, bigint) returns int8_tbl as
-$$select row($1,$2)::int8_tbl$$ language sql;
+$$select row($1,$2)::int8_tbl$$ LANGUAGE SQLTEST;
create function mki4(int) returns int4_tbl as
-$$select row($1)::int4_tbl$$ language sql;
+$$select row($1)::int4_tbl$$ LANGUAGE SQLTEST;
explain (verbose, costs off)
select * from mki8(1,2);
QUERY PLAN
diff --git a/src/test/regress/expected/multirangetypes.out b/src/test/regress/expected/multirangetypes.out
index 04953a5990..656c867d20 100644
--- a/src/test/regress/expected/multirangetypes.out
+++ b/src/test/regress/expected/multirangetypes.out
@@ -2735,7 +2735,7 @@ drop type textrange2;
-- Test polymorphic type system
--
create function anyarray_anymultirange_func(a anyarray, r anymultirange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anymultirange_func(ARRAY[1,2], int4multirange(int4range(10,20)));
anyarray_anymultirange_func
-----------------------------
@@ -2751,16 +2751,16 @@ HINT: No function matches the given name and argument types. You might need to
drop function anyarray_anymultirange_func(anyarray, anymultirange);
-- should fail
create function bogus_func(anyelement)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
-- should fail
create function bogus_func(int)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
create function range_add_bounds(anymultirange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4multirange(int4range(1, 17)));
range_add_bounds
------------------
@@ -2775,7 +2775,7 @@ select range_add_bounds(nummultirange(numrange(1.0001, 123.123)));
create function multirangetypes_sql(q anymultirange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select multirangetypes_sql(int4multirange(int4range(1,10)), ARRAY[2,20]);
multirangetypes_sql
---------------------
@@ -2788,7 +2788,7 @@ LINE 1: select multirangetypes_sql(nummultirange(numrange(1,10)), AR...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
create function anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompatiblemultirange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(int4range(10,20)));
anycompatiblearray_anycompatiblemultirange_func
-------------------------------------------------
@@ -2809,7 +2809,7 @@ LINE 1: select anycompatiblearray_anycompatiblemultirange_func(ARRAY...
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
drop function anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemultirange);
create function anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompatiblemultirange)
- returns anycompatible as 'select lower($1) + lower($2);' language sql;
+ returns anycompatible as 'select lower($1) + lower($2);' LANGUAGE SQLTEST;
select anycompatiblerange_anycompatiblemultirange_func(int4range(1,2), multirange(int4range(10,20)));
anycompatiblerange_anycompatiblemultirange_func
-------------------------------------------------
@@ -2825,7 +2825,7 @@ HINT: No function matches the given name and argument types. You might need to
drop function anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange, anycompatiblemultirange);
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
--
@@ -2902,7 +2902,7 @@ reset enable_sort;
--
-- infer anymultirange from anymultirange
create function mr_outparam_succeed(i anymultirange, out r anymultirange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed(int4multirange(int4range(1,2)));
r | t
---------+-----
@@ -2911,7 +2911,7 @@ select * from mr_outparam_succeed(int4multirange(int4range(1,2)));
-- infer anyarray from anymultirange
create function mr_outparam_succeed2(i anymultirange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed2(int4multirange(int4range(1,2)));
r | t
-----+-----
@@ -2920,7 +2920,7 @@ select * from mr_outparam_succeed2(int4multirange(int4range(1,2)));
-- infer anyrange from anymultirange
create function mr_outparam_succeed3(i anymultirange, out r anyrange, out t text)
- as $$ select range_merge($1), 'foo'::text $$ language sql;
+ as $$ select range_merge($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed3(int4multirange(int4range(1,2)));
r | t
-------+-----
@@ -2929,7 +2929,7 @@ select * from mr_outparam_succeed3(int4multirange(int4range(1,2)));
-- infer anymultirange from anyrange
create function mr_outparam_succeed4(i anyrange, out r anymultirange, out t text)
- as $$ select multirange($1), 'foo'::text $$ language sql;
+ as $$ select multirange($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed4(int4range(1,2));
r | t
---------+-----
@@ -2938,7 +2938,7 @@ select * from mr_outparam_succeed4(int4range(1,2));
-- infer anyelement from anymultirange
create function mr_inoutparam_succeed(out i anyelement, inout r anymultirange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from mr_inoutparam_succeed(int4multirange(int4range(1,2)));
i | r
---+---------
@@ -2947,7 +2947,7 @@ select * from mr_inoutparam_succeed(int4multirange(int4range(1,2)));
-- infer anyelement+anymultirange from anyelement+anymultirange
create function mr_table_succeed(i anyelement, r anymultirange) returns table(i anyelement, r anymultirange)
- as $$ select $1, $2 $$ language sql;
+ as $$ select $1, $2 $$ LANGUAGE SQLTEST;
select * from mr_table_succeed(123, int4multirange(int4range(1,11)));
i | r
-----+----------
@@ -2965,16 +2965,16 @@ select mr_polymorphic(int4range(1, 4));
-- should fail
create function mr_outparam_fail(i anyelement, out r anymultirange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
--should fail
create function mr_inoutparam_fail(inout i anyelement, out r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
--should fail
create function mr_table_fail(i anyelement) returns table(i anyelement, r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
diff --git a/src/test/regress/expected/object_address.out b/src/test/regress/expected/object_address.out
index 388097a695..a03756e41b 100644
--- a/src/test/regress/expected/object_address.out
+++ b/src/test/regress/expected/object_address.out
@@ -32,14 +32,14 @@ CREATE DOMAIN addr_nsp.gendomain AS int4 CONSTRAINT domconstr CHECK (value > 0);
CREATE FUNCTION addr_nsp.trig() RETURNS TRIGGER LANGUAGE plpgsql AS $$ BEGIN END; $$;
CREATE TRIGGER t BEFORE INSERT ON addr_nsp.gentable FOR EACH ROW EXECUTE PROCEDURE addr_nsp.trig();
CREATE POLICY genpol ON addr_nsp.gentable;
-CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQL AS $$ $$;
+CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQLTEST AS $$ $$;
CREATE SERVER "integer" FOREIGN DATA WRAPPER addr_fdw;
CREATE USER MAPPING FOR regress_addr_user SERVER "integer";
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regress_addr_user;
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM regress_addr_user;
-- this transform would be quite unsafe to leave lying around,
-- except that the SQL language pays no attention to transforms:
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
-- suppress warning that depends on wal_level
@@ -482,7 +482,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
policy | | | genpol on addr_nsp.gentable | t
statistics object | addr_nsp | gentable_stat | addr_nsp.gentable_stat | t
collation | pg_catalog | "default" | pg_catalog."default" | t
- transform | | | for integer on language sql | t
+ transform | | | for integer on LANGUAGE SQLTEST | t
text search dictionary | addr_nsp | addr_ts_dict | addr_nsp.addr_ts_dict | t
text search parser | addr_nsp | addr_ts_prs | addr_nsp.addr_ts_prs | t
text search configuration | addr_nsp | addr_ts_conf | addr_nsp.addr_ts_conf | t
@@ -569,7 +569,7 @@ WITH objects (classid, objid, objsubid) AS (VALUES
('pg_policy'::regclass, 0, 0), -- no policy
('pg_publication'::regclass, 0, 0), -- no publication
('pg_publication_rel'::regclass, 0, 0), -- no publication relation
- ('pg_subscription'::regclass, 0, 0), -- no subscription
+ ('pg_sub'::regclass, 0, 0), -- no subscription
('pg_transform'::regclass, 0, 0) -- no transformation
)
SELECT ROW(pg_identify_object(objects.classid, objects.objid, objects.objsubid))
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out
index 6ea169d9ad..9f044f2376 100644
--- a/src/test/regress/expected/plpgsql.out
+++ b/src/test/regress/expected/plpgsql.out
@@ -4358,14 +4358,14 @@ end;
$$ language plpgsql;
-- "limit" is to prevent this from being inlined
create function sql_recurse(float8) returns float8 as
-$$ select recurse($1) limit 1; $$ language sql;
+$$ select recurse($1) limit 1; $$ LANGUAGE SQLTEST;
select recurse(10);
recurse
---------
0
(1 row)
-create function error1(text) returns text language sql as
+create function error1(text) returns text LANGUAGE SQLTEST as
$$ SELECT relname::text FROM pg_class c WHERE c.oid = $1::regclass $$;
create function error2(p_name_table text) returns text language plpgsql as $$
begin
@@ -4391,7 +4391,7 @@ drop function error1(text);
-- Test for proper handling of cast-expression caching
create function sql_to_date(integer) returns date as $$
select $1::text::date
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
create cast (integer as date) with function sql_to_date(integer) as assignment;
create function cast_invoker(integer) returns date as $$
begin
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index 772345584f..648132db4e 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -4,7 +4,7 @@
--
create function polyf(x anyelement) returns anyelement as $$
select x + 1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
int | num
-----+-----
@@ -23,7 +23,7 @@ CONTEXT: SQL function "polyf" during inlining
drop function polyf(x anyelement);
create function polyf(x anyelement) returns anyarray as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
int | num
---------+-----------
@@ -33,7 +33,7 @@ select polyf(42) as int, polyf(4.5) as num;
drop function polyf(x anyelement);
create function polyf(x anyarray) returns anyelement as $$
select x[1]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
int | num
-----+-----
@@ -45,7 +45,7 @@ ERROR: cannot determine element type of "anyarray" argument
drop function polyf(x anyarray);
create function polyf(x anyarray) returns anyarray as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
int | num
-------+-----------
@@ -59,12 +59,12 @@ drop function polyf(x anyarray);
-- fail, can't infer type:
create function polyf(x anyelement) returns anyrange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
create function polyf(x anyrange) returns anyarray as $$
select array[lower(x), upper(x)]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num;
int | num
---------+-----------
@@ -74,7 +74,7 @@ select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num;
drop function polyf(x anyrange);
create function polyf(x anycompatible, y anycompatible) returns anycompatiblearray as $$
select array[x, y]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(2, 4) as int, polyf(2, 4.5) as num;
int | num
-------+---------
@@ -84,7 +84,7 @@ select polyf(2, 4) as int, polyf(2, 4.5) as num;
drop function polyf(x anycompatible, y anycompatible);
create function polyf(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), 11, 2::smallint) as int, polyf(float8range(4.5, 7.8), 7.8, 11::real) as num;
int | num
--------------+------------------
@@ -99,7 +99,7 @@ HINT: No function matches the given name and argument types. You might need to
drop function polyf(x anycompatiblerange, y anycompatible, z anycompatible);
create function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), 11, 2::smallint) as int, polyf(multirange(float8range(4.5, 7.8)), 7.8, 11::real) as num;
int | num
--------------+------------------
@@ -115,12 +115,12 @@ drop function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible)
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblerange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function polyf(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), array[11]) as int, polyf(float8range(4.5, 7.8), array[7]) as num;
int | num
---------+-----------
@@ -131,12 +131,12 @@ drop function polyf(x anycompatiblerange, y anycompatiblearray);
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblemultirange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblemultirange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function polyf(x anycompatiblemultirange, y anycompatiblearray) returns anycompatiblemultirange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), array[11]) as int, polyf(multirange(float8range(4.5, 7.8)), array[7]) as num;
int | num
-----------+-------------
@@ -149,7 +149,7 @@ create function polyf(a anyelement, b anyarray,
OUT x anyarray, OUT y anycompatiblearray)
as $$
select a || b, array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x), y, pg_typeof(y)
from polyf(11, array[1, 2], 42, 34.5);
x | pg_typeof | y | pg_typeof
@@ -216,31 +216,31 @@ drop function polyf(a anyelement, b anyarray,
-- functions, i.e. tf arg1 and tf return type must match
-- polymorphic single arg transfn
CREATE FUNCTION stfp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- non-polymorphic single arg transfn
CREATE FUNCTION stfnp(int[]) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- dual polymorphic transfn
CREATE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- dual non-polymorphic transfn
CREATE FUNCTION tfnp(int[],int) RETURNS int[] AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- arg1 only polymorphic transfn
CREATE FUNCTION tf1p(anyarray,int) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- arg2 only polymorphic transfn
CREATE FUNCTION tf2p(int[],anyelement) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- multi-arg polymorphic
CREATE FUNCTION sum3(anyelement,anyelement,anyelement) returns anyelement AS
-'select $1+$2+$3' language sql strict;
+'select $1+$2+$3' LANGUAGE SQLTEST strict;
-- finalfn polymorphic
CREATE FUNCTION ffp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- finalfn non-polymorphic
CREATE FUNCTION ffnp(int[]) returns int[] as
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- Try to cover all the possible states:
--
-- Note: in Cases 1 & 2, we are trying to return P. Therefore, if the transfn
@@ -731,7 +731,7 @@ begin
return $1;
end$$ language plpgsql;
create function sql_if(bool, anyelement, anyelement) returns anyelement as $$
-select case when $1 then $2 else $3 end $$ language sql;
+select case when $1 then $2 else $3 end $$ LANGUAGE SQLTEST;
-- Note this would fail with integer overflow, never mind wrong bleat() output,
-- if the CASE expression were not successfully inlined
select f1, sql_if(f1 > 0, bleat(f1), bleat(f1 + 1)) from int4_tbl;
@@ -818,9 +818,9 @@ create aggregate build_group(int8, integer) (
);
-- check proper resolution of data types for polymorphic transfn/finalfn
create function first_el_transfn(anyarray, anyelement) returns anyarray as
-'select $1 || $2' language sql immutable;
+'select $1 || $2' LANGUAGE SQLTEST immutable;
create function first_el(anyarray) returns anyelement as
-'select $1[1]' language sql strict immutable;
+'select $1[1]' LANGUAGE SQLTEST strict immutable;
create aggregate first_el_agg_f8(float8) (
SFUNC = array_append,
STYPE = float8[],
@@ -901,7 +901,7 @@ ERROR: cannot accept a value of type anyrange
-- test variadic polymorphic functions
create function myleast(variadic anyarray) returns anyelement as $$
select min($1[i]) from generate_subscripts($1,1) g(i)
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select myleast(10, 1, 20, 33);
myleast
---------
@@ -948,7 +948,7 @@ select myleast(variadic array[]::int[]);
-- an example with some ordinary arguments too
create function concat(text, variadic anyarray) returns text as $$
select array_to_string($2, $1);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select concat('%', 1, 2, 3, 4, 5);
concat
-----------
@@ -977,7 +977,7 @@ drop function concat(text, anyarray);
-- mix variadic with anyelement
create function formarray(anyelement, variadic anyarray) returns anyarray as $$
select array_prepend($1, $2);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select formarray(1,2,3,4,5);
formarray
-------------
@@ -1065,7 +1065,7 @@ select pg_typeof(myleast(10, 1, 20, 33)); -- polymorphic input
-- test basic functionality
create function dfunc(a int = 1, int = 2) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
-------
@@ -1097,12 +1097,12 @@ drop function dfunc(int, int); -- ok
-- fail: defaults must be at end of argument list
create function dfunc(a int = 1, b int) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: input parameters after one with a default value must also have defaults
-- however, this should work:
create function dfunc(a int = 1, out sum int, b int = 2) as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
-------
@@ -1121,7 +1121,7 @@ drop function dfunc(int, int);
-- check implicit coercion
create function dfunc(a int DEFAULT 1.0, int DEFAULT '-1') returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
-------
@@ -1130,7 +1130,7 @@ select dfunc();
create function dfunc(a text DEFAULT 'Hello', b text DEFAULT 'World') returns text as $$
select $1 || ', ' || $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(); -- fail: which dfunc should be called? int or text
ERROR: function dfunc() is not unique
LINE 1: select dfunc();
@@ -1164,10 +1164,10 @@ drop function dfunc(int, int);
drop function dfunc(text, text);
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2, int = 3, int = 4) returns int as $$
select 4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- Now, dfunc(nargs = 2) and dfunc(nargs = 4) are ambiguous when called
-- with 0 to 2 arguments.
select dfunc(); -- fail
@@ -1202,12 +1202,12 @@ drop function dfunc(int, int, int, int);
-- default values are not allowed for output parameters
create function dfunc(out int = 20) returns int as $$
select 1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: only input parameters can have default values
-- polymorphic parameter test
create function dfunc(anyelement = 'World'::text) returns text as $$
select 'Hello, ' || $1::text;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
--------------
@@ -1235,7 +1235,7 @@ select dfunc('City'::text);
drop function dfunc(anyelement);
-- check defaults for variadics
create function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- fail
ERROR: function dfunc() does not exist
LINE 1: select dfunc();
@@ -1254,7 +1254,7 @@ select dfunc(10,20);
(1 row)
create or replace function dfunc(a variadic int[] default array[]::int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- now ok
dfunc
-------
@@ -1275,7 +1275,7 @@ select dfunc(10,20);
-- can't remove the default once it exists
create or replace function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
ERROR: cannot remove parameter defaults from existing function
HINT: Use DROP FUNCTION dfunc(integer[]) first.
\df dfunc
@@ -1289,13 +1289,13 @@ drop function dfunc(a variadic int[]);
-- Ambiguity should be reported only if there's not a better match available
create function dfunc(int = 1, int = 2, int = 3) returns int as $$
select 3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(text) returns text as $$
select $1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- dfunc(narg=2) and dfunc(narg=3) are ambiguous
select dfunc(1); -- fail
ERROR: function dfunc(integer) is not unique
@@ -1318,7 +1318,7 @@ drop function dfunc(text);
create function dfunc(a int, b int, c int = 0, d int = 0)
returns table (a int, b int, c int, d int) as $$
select $1, $2, $3, $4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc(10,20,30)).*;
a | b | c | d
----+----+----+---
@@ -1394,7 +1394,7 @@ drop function dfunc(int, int, int, int);
create function dfunc(a varchar, b numeric, c date = current_date)
returns table (a varchar, b numeric, c date) as $$
select $1, $2, $3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc('Hello World', 20, '2009-07-25'::date)).*;
a | b | c
-------------+----+------------
@@ -1435,7 +1435,7 @@ drop function dfunc(varchar, numeric, date);
create function dfunc(a varchar = 'def a', out _a varchar, c numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc()).*;
_a | _c
-------+----
@@ -1488,27 +1488,27 @@ select * from dfunc(c := 100);
create or replace function dfunc(a varchar = 'def a', out _a varchar, x numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot change name of input parameter "c"
HINT: Use DROP FUNCTION dfunc(character varying,numeric) first.
create or replace function dfunc(a varchar = 'def a', out _a varchar, numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot change name of input parameter "c"
HINT: Use DROP FUNCTION dfunc(character varying,numeric) first.
drop function dfunc(varchar, numeric);
--fail, named parameters are not unique
-create function testpolym(a int, a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(a int, a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-create function testpolym(a int, inout a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-- valid
-create function testpolym(a int, out a int) returns int as $$ select $1;$$ language sql;
+create function testpolym(a int, out a int) returns int as $$ select $1;$$ LANGUAGE SQLTEST;
select testpolym(37);
testpolym
-----------
@@ -1516,7 +1516,7 @@ select testpolym(37);
(1 row)
drop function testpolym(int);
-create function testpolym(a int) returns table(a int) as $$ select $1;$$ language sql;
+create function testpolym(a int) returns table(a int) as $$ select $1;$$ LANGUAGE SQLTEST;
select * from testpolym(37);
a
----
@@ -1528,7 +1528,7 @@ drop function testpolym(int);
create function dfunc(a anyelement, b anyelement = null, flag bool = true)
returns anyelement as $$
select case when $3 then $1 else $2 end;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(1,2);
dfunc
-------
@@ -1749,7 +1749,7 @@ drop function dfunc(anyelement, anyelement, bool);
create function anyctest(anycompatible, anycompatible)
returns anycompatible as $$
select greatest($1, $2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
----+-----------
@@ -1777,7 +1777,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatible)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
---------+-----------
@@ -1799,7 +1799,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatiblearray)
returns anycompatiblearray as $$
select array[$1] || $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[12]) x;
x | pg_typeof
---------+-----------
@@ -1838,7 +1838,7 @@ drop function anyctest(anycompatible, anycompatiblearray);
create function anyctest(anycompatible, anycompatiblerange)
returns anycompatiblerange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, int4range(4,7)) x;
x | pg_typeof
-------+-----------
@@ -1867,7 +1867,7 @@ drop function anyctest(anycompatible, anycompatiblerange);
create function anyctest(anycompatiblerange, anycompatiblerange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(int4range(11,12), int4range(4,7)) x;
x | pg_typeof
----+-----------
@@ -1884,13 +1884,13 @@ drop function anyctest(anycompatiblerange, anycompatiblerange);
create function anyctest(anycompatible)
returns anycompatiblerange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function anyctest(anycompatible, anycompatiblemultirange)
returns anycompatiblemultirange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, multirange(int4range(4,7))) x;
x | pg_typeof
---------+----------------
@@ -1919,7 +1919,7 @@ drop function anyctest(anycompatible, anycompatiblemultirange);
create function anyctest(anycompatiblemultirange, anycompatiblemultirange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(int4range(4,7))) x;
x | pg_typeof
----+-----------
@@ -1936,13 +1936,13 @@ drop function anyctest(anycompatiblemultirange, anycompatiblemultirange);
create function anyctest(anycompatible)
returns anycompatiblemultirange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblemultirange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function anyctest(anycompatiblenonarray, anycompatiblenonarray)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
---------+-----------
@@ -1965,7 +1965,7 @@ create function anyctest(a anyelement, b anyarray,
c anycompatible, d anycompatible)
returns anycompatiblearray as $$
select array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[1, 2], 42, 34.5) x;
x | pg_typeof
-----------+-----------
@@ -1994,7 +1994,7 @@ drop function anyctest(a anyelement, b anyarray,
create function anyctest(variadic anycompatiblearray)
returns anycompatiblearray as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
---------+-----------
diff --git a/src/test/regress/expected/portals.out b/src/test/regress/expected/portals.out
index dc0d2ef7dd..09c07bd9d4 100644
--- a/src/test/regress/expected/portals.out
+++ b/src/test/regress/expected/portals.out
@@ -779,7 +779,7 @@ BEGIN;
CREATE FUNCTION declares_cursor(text)
RETURNS void
AS 'DECLARE c CURSOR FOR SELECT stringu1 FROM tenk1 WHERE stringu1 LIKE $1;'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT declares_cursor('AB%');
declares_cursor
-----------------
@@ -814,9 +814,9 @@ ROLLBACK;
--
create temp table tt1(f1 int);
create function count_tt1_v() returns int8 as
-'select count(*) from tt1' language sql volatile;
+'select count(*) from tt1' LANGUAGE SQLTEST volatile;
create function count_tt1_s() returns int8 as
-'select count(*) from tt1' language sql stable;
+'select count(*) from tt1' LANGUAGE SQLTEST stable;
begin;
insert into tt1 values(1);
declare c1 cursor for select count_tt1_v(), count_tt1_s();
@@ -1359,7 +1359,7 @@ DROP TABLE cursor;
-- per bug report in 8336843.9833.1399385291498.JavaMail.root@quick
begin;
create function nochange(int) returns int
- as 'select $1 limit 1' language sql stable;
+ as 'select $1 limit 1' LANGUAGE SQLTEST stable;
declare c cursor for select * from int8_tbl limit nochange(3);
fetch all from c;
q1 | q2
diff --git a/src/test/regress/expected/privileges.out b/src/test/regress/expected/privileges.out
index 7754c20db4..6b01922846 100644
--- a/src/test/regress/expected/privileges.out
+++ b/src/test/regress/expected/privileges.out
@@ -737,18 +737,18 @@ END;
-- privileges on functions, languages
-- switch to superuser
\c -
-REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user1; -- ok
+REVOKE ALL PRIVILEGES ON LANGUAGE sqltest FROM PUBLIC;
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user1; -- ok
GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
ERROR: language "c" is not trusted
DETAIL: GRANT and REVOKE are not allowed on untrusted languages, because only superusers can use untrusted languages.
SET SESSION AUTHORIZATION regress_priv_user1;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user2; -- fail
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user2; -- fail
WARNING: no privileges were granted for "sql"
-CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql;
-CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest;
+CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE priv_testagg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sql;
+CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sqltest;
REVOKE ALL ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) TO regress_priv_user2;
REVOKE ALL ON FUNCTION priv_testproc1(int) FROM PUBLIC; -- fail, not a function
@@ -768,7 +768,7 @@ GRANT ALL PRIVILEGES ON FUNCTION priv_testagg1(int) TO regress_priv_user4;
GRANT ALL PRIVILEGES ON PROCEDURE priv_testproc1(int) TO regress_priv_user4;
CREATE FUNCTION priv_testfunc4(boolean) RETURNS text
AS 'select col1 from atest2 where col2 = $1;'
- LANGUAGE sql SECURITY DEFINER;
+ LANGUAGE sqltest SECURITY DEFINER;
GRANT EXECUTE ON FUNCTION priv_testfunc4(boolean) TO regress_priv_user3;
SET SESSION AUTHORIZATION regress_priv_user2;
SELECT priv_testfunc1(5), priv_testfunc2(5); -- ok
@@ -777,8 +777,8 @@ SELECT priv_testfunc1(5), priv_testfunc2(5); -- ok
10 | 15
(1 row)
-CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail
-ERROR: permission denied for language sql
+CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest; -- fail
+ERROR: permission denied for LANGUAGE SQLTEST
SELECT priv_testagg1(x) FROM (VALUES (1), (2), (3)) _(x); -- ok
priv_testagg1
---------------
@@ -824,7 +824,7 @@ ERROR: must be owner of procedure priv_testproc1
\c -
DROP FUNCTION priv_testfunc1(int); -- ok
-- restore to sanity
-GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
+GRANT ALL PRIVILEGES ON LANGUAGE sqltest TO PUBLIC;
-- verify privilege checks on array-element coercions
BEGIN;
SELECT '{1}'::int4[]::int8[];
@@ -866,14 +866,14 @@ ERROR: permission denied for type priv_testdomain1
CREATE DOMAIN priv_testdomain2a AS priv_testdomain1;
ERROR: permission denied for type priv_testdomain1
CREATE DOMAIN priv_testdomain3a AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3a) WITH FUNCTION castfunc(int);
ERROR: permission denied for type priv_testdomain1
DROP FUNCTION castfunc(int) CASCADE;
DROP DOMAIN priv_testdomain3a;
-CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
ERROR: permission denied for type priv_testdomain1
-CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
ERROR: permission denied for type priv_testdomain1
CREATE OPERATOR !+! (PROCEDURE = int4pl, LEFTARG = priv_testdomain1, RIGHTARG = priv_testdomain1);
ERROR: permission denied for type priv_testdomain1
@@ -904,11 +904,11 @@ SET SESSION AUTHORIZATION regress_priv_user2;
CREATE AGGREGATE priv_testagg1b(priv_testdomain1) (sfunc = int4_sum, stype = bigint);
CREATE DOMAIN priv_testdomain2b AS priv_testdomain1;
CREATE DOMAIN priv_testdomain3b AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3b) WITH FUNCTION castfunc(int);
WARNING: cast will be ignored because the source data type is a domain
-CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
-CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
CREATE OPERATOR !! (PROCEDURE = priv_testfunc5b, RIGHTARG = priv_testdomain1);
CREATE TABLE test5b (a int, b priv_testdomain1);
CREATE TABLE test6b OF priv_testtype1;
@@ -1330,9 +1330,9 @@ SELECT has_table_privilege('regress_priv_user1', 'atest4', 'SELECT WITH GRANT OP
\c -
CREATE ROLE regress_sro_user;
SET SESSION AUTHORIZATION regress_sro_user;
-CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sql AS
+CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sqltest AS
'GRANT regress_priv_group2 TO regress_sro_user';
-CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'DECLARE c CURSOR WITH HOLD FOR SELECT unwanted_grant(); SELECT true';
-- REFRESH of this MV will queue a GRANT at end of transaction
CREATE MATERIALIZED VIEW sro_mv AS SELECT mv_action() WITH NO DATA;
@@ -1351,7 +1351,7 @@ CREATE FUNCTION sro_trojan() RETURNS trigger LANGUAGE plpgsql AS
CREATE CONSTRAINT TRIGGER t AFTER INSERT ON sro_trojan_table
INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE sro_trojan();
-- Now, REFRESH will issue such an INSERT, queueing the GRANT
-CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'INSERT INTO sro_trojan_table DEFAULT VALUES; SELECT true';
REFRESH MATERIALIZED VIEW sro_mv;
ERROR: cannot fire deferred trigger within security-restricted operation
@@ -1370,7 +1370,7 @@ DROP OWNED BY regress_sro_user;
DROP ROLE regress_sro_user;
-- Admin options
SET SESSION AUTHORIZATION regress_priv_user4;
-CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: had ADMIN OPTION
SET ROLE regress_priv_group2;
@@ -1392,7 +1392,7 @@ ERROR: must have admin option on role "regress_priv_group2"
SET SESSION AUTHORIZATION regress_priv_group2;
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: a role can self-admin
NOTICE: role "regress_priv_user5" is already a member of role "regress_priv_group2"
-CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
SELECT dogrant_fails(); -- fails: no self-admin in SECURITY DEFINER
ERROR: must have admin option on role "regress_priv_group2"
@@ -1773,9 +1773,9 @@ SELECT has_schema_privilege('regress_priv_user2', 'testns5', 'CREATE'); -- no
(1 row)
SET ROLE regress_priv_user1;
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- no
has_function_privilege
------------------------
@@ -1796,11 +1796,11 @@ SELECT has_function_privilege('regress_priv_user2', 'testns.bar()', 'EXECUTE');
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT EXECUTE ON ROUTINES to public;
DROP FUNCTION testns.foo();
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
DROP AGGREGATE testns.agg1(int);
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
DROP PROCEDURE testns.bar();
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- yes
has_function_privilege
------------------------
@@ -1899,9 +1899,9 @@ SELECT has_table_privilege('regress_priv_user1', 'testns.t2', 'SELECT'); -- fals
f
(1 row)
-CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE testns.priv_testagg(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sql;
+CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user1', 'testns.priv_testfunc(int)', 'EXECUTE'); -- true by default
has_function_privilege
------------------------
@@ -2086,7 +2086,7 @@ SELECT lo_unlink(oid) FROM pg_largeobject_metadata WHERE oid >= 1000 AND oid < 3
DROP GROUP regress_priv_group1;
DROP GROUP regress_priv_group2;
-- these are needed to clean up permissions
-REVOKE USAGE ON LANGUAGE sql FROM regress_priv_user1;
+REVOKE USAGE ON LANGUAGE sqltest FROM regress_priv_user1;
DROP OWNED BY regress_priv_user1;
DROP USER regress_priv_user1;
DROP USER regress_priv_user2;
diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out
index 5bbd5f6c0b..3621a29cf1 100644
--- a/src/test/regress/expected/rangefuncs.out
+++ b/src/test/regress/expected/rangefuncs.out
@@ -2,7 +2,7 @@ CREATE TABLE rngfunc2(rngfuncid int, f2 int);
INSERT INTO rngfunc2 VALUES(1, 11);
INSERT INTO rngfunc2 VALUES(2, 22);
INSERT INTO rngfunc2 VALUES(1, 111);
-CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQL;
+CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQLTEST;
-- function with ORDINALITY
select * from rngfunct(1) with ordinality as z(a,b,ord);
a | b | ord
@@ -340,7 +340,7 @@ INSERT INTO rngfunc VALUES(1,1,'Joe');
INSERT INTO rngfunc VALUES(1,2,'Ed');
INSERT INTO rngfunc VALUES(2,1,'Mary');
-- sql, proretset = f, prorettype = b
-CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc1(1) AS t1;
t1
----
@@ -370,7 +370,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc2(1) AS t1;
t1
----
@@ -404,7 +404,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc3(1) AS t1;
t1
-----
@@ -438,7 +438,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = c
-CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc4(1) AS t1;
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -468,7 +468,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = c
-CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc5(1) AS t1;
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -502,7 +502,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = record
-CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc6(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -535,7 +535,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = record
-CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc7(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -697,7 +697,7 @@ DROP TABLE rngfunc;
CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq1;
CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq2;
CREATE TYPE rngfunc_rescan_t AS (i integer, s bigint);
-CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQL;
+CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQLTEST;
-- plpgsql functions use materialize mode
CREATE FUNCTION rngfunc_mat(int,int) RETURNS setof rngfunc_rescan_t AS 'begin for i in $1..$2 loop return next (i, nextval(''rngfunc_rescan_seq2'')); end loop; end;' LANGUAGE plpgsql;
--invokes ExecReScanFunctionScan - all these cases should materialize the function only once
@@ -1424,7 +1424,7 @@ DROP SEQUENCE rngfunc_rescan_seq2;
-- Test cases involving OUT parameters
--
CREATE FUNCTION rngfunc(in f1 int, out f2 int)
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
SELECT rngfunc(42);
rngfunc
---------
@@ -1445,22 +1445,22 @@ SELECT * FROM rngfunc(42) AS p(x);
-- explicit spec of return type is OK
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
-- error, wrong result type
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS float
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
ERROR: function result type must be integer because of OUT parameters
-- with multiple OUT params you must get a RECORD result
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
ERROR: function result type must be record because of OUT parameters
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text)
RETURNS record
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
ERROR: cannot change return type of existing function
HINT: Use DROP FUNCTION rngfunc(integer) first.
CREATE OR REPLACE FUNCTION rngfuncr(in f1 int, out f2 int, out text)
-AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncr(f1) FROM int4_tbl;
f1 | rngfuncr
-------------+----------------------------
@@ -1484,7 +1484,7 @@ SELECT * FROM rngfuncr(42) AS p(a,b);
(1 row)
CREATE OR REPLACE FUNCTION rngfuncb(in f1 int, inout f2 int, out text)
-AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncb(f1, f1/2) FROM int4_tbl;
f1 | rngfuncb
-------------+----------------------------
@@ -1515,7 +1515,7 @@ DROP FUNCTION rngfuncb(in f1 int, inout f2 int);
-- For my next trick, polymorphic OUT parameters
--
CREATE FUNCTION dup (f1 anyelement, f2 out anyelement, f3 out anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
dup
----------------
@@ -1538,13 +1538,13 @@ SELECT * FROM dup('xyz'::text);
-- fails, as we are attempting to rename first argument
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
ERROR: cannot change name of input parameter "f1"
HINT: Use DROP FUNCTION dup(anyelement) first.
DROP FUNCTION dup(anyelement);
-- equivalent behavior, though different name exposed for input arg
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
dup
----------------
@@ -1554,11 +1554,11 @@ SELECT dup(22);
DROP FUNCTION dup(anyelement);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 int, out f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
ERROR: cannot determine result data type
DETAIL: A result of type anyelement requires at least one input of type anyelement, anyarray, anynonarray, anyenum, anyrange, or anymultirange.
CREATE FUNCTION dup (f1 anycompatible, f2 anycompatiblearray, f3 out anycompatible, f4 out anycompatiblearray)
-AS 'select $1, $2' LANGUAGE sql;
+AS 'select $1, $2' LANGUAGE sqltest;
SELECT dup(22, array[44]);
dup
-----------
@@ -1585,7 +1585,7 @@ SELECT *, pg_typeof(f3), pg_typeof(f4) FROM dup(22, array[44::bigint]);
DROP FUNCTION dup(f1 anycompatible, f2 anycompatiblearray);
CREATE FUNCTION dup (f1 anycompatiblerange, f2 out anycompatible, f3 out anycompatiblearray, f4 out anycompatiblerange)
-AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sql;
+AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sqltest;
SELECT dup(int4range(4,7));
dup
---------------------
@@ -1607,7 +1607,7 @@ SELECT dup(textrange('aaa', 'bbb'));
DROP FUNCTION dup(f1 anycompatiblerange);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 anyarray, out f2 anycompatible, out f3 anycompatiblearray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatible requires at least one input of type anycompatible, anycompatiblearray, anycompatiblenonarray, or anycompatiblerange.
--
@@ -1615,7 +1615,7 @@ DETAIL: A result of type anycompatible requires at least one input of type anyc
--
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a int)
-AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sql;
+AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc();
a
---
@@ -1631,7 +1631,7 @@ CREATE OR REPLACE FUNCTION rngfunc(int)
RETURNS TABLE(a int, b int)
AS $$ SELECT a, b
FROM generate_series(1,$1) a(a),
- generate_series(1,$1) b(b) $$ LANGUAGE sql;
+ generate_series(1,$1) b(b) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc(3);
a | b
---+---
@@ -1650,7 +1650,7 @@ DROP FUNCTION rngfunc(int);
-- case that causes change of typmod knowledge during inlining
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a varchar(5))
-AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sql STABLE;
+AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sqltest STABLE;
SELECT * FROM rngfunc() GROUP BY 1;
a
-------
@@ -1664,7 +1664,7 @@ DROP FUNCTION rngfunc();
create temp table tt(f1 serial, data text);
create function insert_tt(text) returns int as
$$ insert into tt(data) values($1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('foo');
insert_tt
-----------
@@ -1687,7 +1687,7 @@ select * from tt;
-- insert will execute to completion even if function needs just 1 row
create or replace function insert_tt(text) returns int as
$$ insert into tt(data) values($1),($1||$1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('fool');
insert_tt
-----------
@@ -1706,7 +1706,7 @@ select * from tt;
-- setof does what's expected
create or replace function insert_tt2(text,text) returns setof int as
$$ insert into tt(data) values($1),($2) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt2('foolish','barrish');
insert_tt2
------------
@@ -1832,7 +1832,7 @@ select * from tt_log;
-- test case for a whole-row-variable bug
create function rngfunc1(n integer, out a text, out b text)
returns setof record
- language sql
+ LANGUAGE SQLTEST
as $$ select 'foo ' || i, 'bar ' || i from generate_series(1,$1) i $$;
set work_mem='64kB';
select t.a, t, t.a from rngfunc1(10000) t limit 1;
@@ -1854,7 +1854,7 @@ drop function rngfunc1(n integer);
-- the actual record type ...
create function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql strict immutable;
+$$ LANGUAGE SQLTEST strict immutable;
select array_to_set(array['one', 'two']);
array_to_set
--------------
@@ -1899,7 +1899,7 @@ explain (verbose, costs off)
-- but without, it can be:
create or replace function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select array_to_set(array['one', 'two']);
array_to_set
--------------
@@ -1937,7 +1937,7 @@ explain (verbose, costs off)
create temp table rngfunc(f1 int8, f2 int8);
create function testrngfunc() returns record as $$
insert into rngfunc values (1,2) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
testrngfunc
-------------
@@ -1957,7 +1957,7 @@ LINE 1: select * from testrngfunc();
drop function testrngfunc();
create function testrngfunc() returns setof record as $$
insert into rngfunc values (1,2), (3,4) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
testrngfunc
-------------
@@ -1981,7 +1981,7 @@ drop function testrngfunc();
create type rngfunc_type as (f1 numeric(35,6), f2 numeric(35,2));
create function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2013,7 +2013,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2046,7 +2046,7 @@ select * from testrngfunc();
drop function testrngfunc();
create function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2078,7 +2078,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2111,7 +2111,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 1, 2 union select 3, 4 order by 1;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2177,7 +2177,7 @@ insert into users values ('id2',2,'email2',true,12,true);
alter table users drop column todrop;
create or replace function get_first_user() returns users as
$$ SELECT * FROM users ORDER BY userid LIMIT 1; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_first_user();
get_first_user
-------------------
@@ -2192,7 +2192,7 @@ SELECT * FROM get_first_user();
create or replace function get_users() returns setof users as
$$ SELECT * FROM users ORDER BY userid; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_users();
get_users
---------------------
@@ -2263,7 +2263,7 @@ drop table users;
-- check behavior with type coercion required for a set-op
create or replace function rngfuncbar() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar ; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select rngfuncbar();
rngfuncbar
------------
@@ -2294,7 +2294,7 @@ explain (verbose, costs off) select * from rngfuncbar();
drop function rngfuncbar();
-- check handling of a SQL function with multiple OUT params (bug #5777)
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1) $$ language sql;
+$$ select (1, 2.1) $$ LANGUAGE SQLTEST;
select * from rngfuncbar();
column1 | column2
---------+---------
@@ -2302,12 +2302,12 @@ select * from rngfuncbar();
(1 row)
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2) $$ language sql;
+$$ select (1, 2) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
ERROR: function return row and query-specified return row do not match
DETAIL: Returned type integer at ordinal position 2, but query expects numeric.
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1, 3) $$ language sql;
+$$ select (1, 2.1, 3) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
ERROR: function return row and query-specified return row do not match
DETAIL: Returned row contains 3 attributes, but query expects 2.
@@ -2315,7 +2315,7 @@ drop function rngfuncbar();
-- check whole-row-Var handling in nested lateral functions (bug #11703)
create function extractq2(t int8_tbl) returns int8 as $$
select t.q2
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2(int8_tbl) f(x);
QUERY PLAN
@@ -2341,7 +2341,7 @@ select x from int8_tbl, extractq2(int8_tbl) f(x);
create function extractq2_2(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t) offset 0
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2(int8_tbl) f(x);
QUERY PLAN
@@ -2367,7 +2367,7 @@ select x from int8_tbl, extractq2_2(int8_tbl) f(x);
-- without the "offset 0", this function gets optimized quite differently
create function extractq2_2_opt(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t)
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x);
QUERY PLAN
diff --git a/src/test/regress/expected/rangetypes.out b/src/test/regress/expected/rangetypes.out
index 05b882fde9..fa66386ed6 100644
--- a/src/test/regress/expected/rangetypes.out
+++ b/src/test/regress/expected/rangetypes.out
@@ -1539,7 +1539,7 @@ drop type textrange2;
-- Test polymorphic type system
--
create function anyarray_anyrange_func(a anyarray, r anyrange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anyrange_func(ARRAY[1,2], int4range(10,20));
anyarray_anyrange_func
------------------------
@@ -1555,16 +1555,16 @@ HINT: No function matches the given name and argument types. You might need to
drop function anyarray_anyrange_func(anyarray, anyrange);
-- should fail
create function bogus_func(anyelement)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
-- should fail
create function bogus_func(int)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
create function range_add_bounds(anyrange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4range(1, 17));
range_add_bounds
------------------
@@ -1579,7 +1579,7 @@ select range_add_bounds(numrange(1.0001, 123.123));
create function rangetypes_sql(q anyrange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select rangetypes_sql(int4range(1,10), ARRAY[2,20]);
rangetypes_sql
----------------
@@ -1592,7 +1592,7 @@ LINE 1: select rangetypes_sql(numrange(1,10), ARRAY[2,20]);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
create function anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatiblerange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], int4range(10,20));
anycompatiblearray_anycompatiblerange_func
--------------------------------------------
@@ -1614,7 +1614,7 @@ HINT: No function matches the given name and argument types. You might need to
drop function anycompatiblearray_anycompatiblerange_func(anycompatiblearray, anycompatiblerange);
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
--
@@ -1696,7 +1696,7 @@ reset enable_sort;
--
-- infer anyrange from anyrange
create function outparam_succeed(i anyrange, out r anyrange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed(int4range(1,2));
r | t
-------+-----
@@ -1705,7 +1705,7 @@ select * from outparam_succeed(int4range(1,2));
create function outparam2_succeed(r anyrange, out lu anyarray, out ul anyarray)
as $$ select array[lower($1), upper($1)], array[upper($1), lower($1)] $$
- language sql;
+ LANGUAGE SQLTEST;
select * from outparam2_succeed(int4range(1,11));
lu | ul
--------+--------
@@ -1714,7 +1714,7 @@ select * from outparam2_succeed(int4range(1,11));
-- infer anyarray from anyrange
create function outparam_succeed2(i anyrange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed2(int4range(int4range(1,2)));
r | t
-----+-----
@@ -1723,7 +1723,7 @@ select * from outparam_succeed2(int4range(int4range(1,2)));
-- infer anyelement from anyrange
create function inoutparam_succeed(out i anyelement, inout r anyrange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from inoutparam_succeed(int4range(1,2));
i | r
---+-------
@@ -1733,7 +1733,7 @@ select * from inoutparam_succeed(int4range(1,2));
create function table_succeed(r anyrange)
returns table(l anyelement, u anyelement)
as $$ select lower($1), upper($1) $$
- language sql;
+ LANGUAGE SQLTEST;
select * from table_succeed(int4range(1,11));
l | u
---+----
@@ -1742,16 +1742,16 @@ select * from table_succeed(int4range(1,11));
-- should fail
create function outparam_fail(i anyelement, out r anyrange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
--should fail
create function inoutparam_fail(inout i anyelement, out r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
--should fail
create function table_fail(i anyelement) returns table(i anyelement, r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
diff --git a/src/test/regress/expected/rowtypes.out b/src/test/regress/expected/rowtypes.out
index 0e71baf8fb..4b187582b2 100644
--- a/src/test/regress/expected/rowtypes.out
+++ b/src/test/regress/expected/rowtypes.out
@@ -841,10 +841,10 @@ CREATE TYPE price_key AS (
);
CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
insert into price values (1,false,42), (10,false,100), (11,true,17.99);
UPDATE price
SET active = true, price = input_prices.price
@@ -866,20 +866,20 @@ rollback;
create temp table compos (f1 int, f2 text);
create function fcompos1(v compos) returns void as $$
insert into compos values (v); -- fail
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: column "f1" is of type integer but expression is of type compos
LINE 2: insert into compos values (v); -- fail
^
HINT: You will need to rewrite or cast the expression.
create function fcompos1(v compos) returns void as $$
insert into compos values (v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos2(v compos) returns void as $$
select fcompos1(v);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos3(v compos) returns void as $$
select fcompos1(fcompos3.v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select fcompos1(row(1,'one'));
fcompos1
----------
@@ -968,7 +968,7 @@ select last(f) from fullname f;
Blow
(1 row)
-create function longname(fullname) returns text language sql
+create function longname(fullname) returns text LANGUAGE SQLTEST
as $$select $1.first || ' ' || $1.last$$;
select f.longname from fullname f;
longname
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 6173473de9..b55e47b8fc 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -764,7 +764,7 @@ create view rtest_vview4 as select X.a, X.b, count(Y.a) as refcount
group by X.a, X.b;
create function rtest_viewfunc1(int4) returns int4 as
'select count(*)::int4 from rtest_view2 where a = $1'
- language sql;
+ LANGUAGE SQLTEST;
create view rtest_vview5 as select a, b, rtest_viewfunc1(a) as refcount
from rtest_view1;
insert into rtest_view1 values (1, 'item 1', 't');
@@ -1654,7 +1654,7 @@ UNION ALL
l.provider,
l.label
FROM (pg_shseclabel l
- JOIN pg_subscription s ON (((l.classoid = s.tableoid) AND (l.objoid = s.oid))))
+ JOIN pg_sub s ON (((l.classoid = s.tableoid) AND (l.objoid = s.oid))))
UNION ALL
SELECT l.objoid,
l.classoid,
@@ -2064,17 +2064,17 @@ pg_stat_ssl| SELECT s.pid,
s.ssl_issuer_dn AS issuer_dn
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid)
WHERE (s.client_port IS NOT NULL);
-pg_stat_subscription| SELECT su.oid AS subid,
+pg_stat_sub| SELECT su.oid AS subid,
su.subname,
st.pid,
st.relid,
st.received_lsn,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_location,
st.latest_end_time
- FROM (pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL::oid) st(subid, relid, pid, received_lsn, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time) ON ((st.subid = su.oid)));
+ FROM (pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL::oid) st(subid, relid, pid, received_lsn, last_msg_send_time, last_msg_receipt_time, latest_end_location, latest_end_time) ON ((st.subid = su.oid)));
pg_stat_sys_indexes| SELECT pg_stat_all_indexes.relid,
pg_stat_all_indexes.indexrelid,
pg_stat_all_indexes.schemaname,
@@ -2169,13 +2169,13 @@ pg_stat_wal_receiver| SELECT s.pid,
s.received_tli,
s.last_msg_send_time,
s.last_msg_receipt_time,
- s.latest_end_lsn,
+ s.latest_end_location,
s.latest_end_time,
s.slot_name,
s.sender_host,
s.sender_port,
s.conninfo
- FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time, slot_name, sender_host, sender_port, conninfo)
+ FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_location, latest_end_time, slot_name, sender_host, sender_port, conninfo)
WHERE (s.pid IS NOT NULL);
pg_stat_xact_all_tables| SELECT c.oid AS relid,
n.nspname AS schemaname,
@@ -3424,7 +3424,7 @@ drop table hat_data;
-- Note that the function is kept around to stress pg_dump.
CREATE FUNCTION func_with_set_params() RETURNS integer
AS 'select 1;'
- LANGUAGE SQL
+ LANGUAGE SQLTEST
SET search_path TO PG_CATALOG
SET extra_float_digits TO 2
SET work_mem TO '4MB'
@@ -3436,7 +3436,7 @@ SELECT pg_get_functiondef('func_with_set_params()'::regprocedure);
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION public.func_with_set_params() +
RETURNS integer +
- LANGUAGE sql +
+ LANGUAGE sqltest +
IMMUTABLE STRICT +
SET search_path TO 'pg_catalog' +
SET extra_float_digits TO '2' +
diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out
index d9ce961be2..a1c612b5bd 100644
--- a/src/test/regress/expected/sanity_check.out
+++ b/src/test/regress/expected/sanity_check.out
@@ -151,8 +151,8 @@ pg_shseclabel|t
pg_statistic|t
pg_statistic_ext|t
pg_statistic_ext_data|t
-pg_subscription|t
-pg_subscription_rel|t
+pg_sub|t
+pg_sub_rel|t
pg_tablespace|t
pg_transform|t
pg_trigger|t
diff --git a/src/test/regress/expected/select.out b/src/test/regress/expected/select.out
index c441049f41..494911ffb6 100644
--- a/src/test/regress/expected/select.out
+++ b/src/test/regress/expected/select.out
@@ -915,7 +915,7 @@ SELECT 1 AS x ORDER BY x;
-- But ORDER BY on a set-valued expression does
create function sillysrf(int) returns setof int as
- 'values (1),(10),(2),($1)' language sql immutable;
+ 'values (1),(10),(2),($1)' LANGUAGE SQLTEST immutable;
select sillysrf(42);
sillysrf
----------
diff --git a/src/test/regress/expected/select_into.out b/src/test/regress/expected/select_into.out
index 43b8209d22..34e9503367 100644
--- a/src/test/regress/expected/select_into.out
+++ b/src/test/regress/expected/select_into.out
@@ -133,7 +133,7 @@ DROP TABLE ctas_nodata_4;
CREATE FUNCTION make_table() RETURNS VOID
AS $$
CREATE TABLE created_table AS SELECT * FROM int8_tbl;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
SELECT make_table();
make_table
------------
diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out
index 9b0c418db7..cf56b27664 100644
--- a/src/test/regress/expected/select_parallel.out
+++ b/src/test/regress/expected/select_parallel.out
@@ -124,7 +124,7 @@ reset enable_parallel_append;
-- Parallel Append that runs serially
create function sp_test_func() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select sp_test_func() order by 1;
sp_test_func
--------------
diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out
index 2fa9bce66a..54ab1efd06 100644
--- a/src/test/regress/expected/subscription.out
+++ b/src/test/regress/expected/subscription.out
@@ -31,7 +31,7 @@ ERROR: publication name "foo" used more than once
CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false);
WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables
COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription';
-SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
+SELECT obj_description(s.oid, 'pg_sub') FROM pg_sub s;
obj_description
-------------------
test subscription
diff --git a/src/test/regress/expected/subselect.out b/src/test/regress/expected/subselect.out
index d5532d0ccc..ec73a50e30 100644
--- a/src/test/regress/expected/subselect.out
+++ b/src/test/regress/expected/subselect.out
@@ -811,7 +811,7 @@ HINT: No operator matches the given name and argument types. You might need to
begin;
-- make an operator to allow it to succeed
create function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2';
create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text);
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
@@ -833,7 +833,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function results in unusual number of hash clauses,
-- which we can still cope with
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2 and $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2 and $1::text = $2';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
QUERY PLAN
@@ -854,7 +854,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function causes LHS and RHS to be switched,
-- which we can't cope with, so hashing should be abandoned
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $2 = $1::text';
+LANGUAGE SQLTEST as 'select $2 = $1::text';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
QUERY PLAN
diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/temp.out
index a5b3ed34a3..1033b844c6 100644
--- a/src/test/regress/expected/temp.out
+++ b/src/test/regress/expected/temp.out
@@ -149,9 +149,9 @@ insert into public.whereami values ('public');
create temp table whereami (f1 text);
insert into whereami values ('temp');
create function public.whoami() returns text
- as $$select 'public'::text$$ language sql;
+ as $$select 'public'::text$$ LANGUAGE SQLTEST;
create function pg_temp.whoami() returns text
- as $$select 'temp'::text$$ language sql;
+ as $$select 'temp'::text$$ LANGUAGE SQLTEST;
-- default should have pg_temp implicitly first, but only for tables
select * from whereami;
f1
@@ -326,12 +326,12 @@ drop table temp_inh_oncommit_test;
-- Function creation
begin;
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
prepare transaction 'twophase_func';
ERROR: cannot PREPARE a transaction that has operated on temporary objects
-- Function drop
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
begin;
drop function pg_temp.twophase_func();
prepare transaction 'twophase_func';
diff --git a/src/test/regress/expected/transactions.out b/src/test/regress/expected/transactions.out
index 1b03310029..68153b45d3 100644
--- a/src/test/regress/expected/transactions.out
+++ b/src/test/regress/expected/transactions.out
@@ -472,7 +472,7 @@ select * from xacttest;
777 | 777.777
(5 rows)
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' stable;
begin;
update xacttest set a = max_xacttest() + 10 where a > 0;
@@ -488,7 +488,7 @@ select * from xacttest;
rollback;
-- But a volatile function can see the partial results of the calling query
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' volatile;
begin;
update xacttest set a = max_xacttest() + 10 where a > 0;
diff --git a/src/test/regress/expected/typed_table.out b/src/test/regress/expected/typed_table.out
index 2e47ecbcf5..d70baad15d 100644
--- a/src/test/regress/expected/typed_table.out
+++ b/src/test/regress/expected/typed_table.out
@@ -18,7 +18,7 @@ SELECT * FROM persons;
Typed table of type: person_type
CREATE FUNCTION get_all_persons() RETURNS SETOF person_type
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT * FROM persons;
$$;
@@ -95,7 +95,7 @@ DROP TABLE stuff;
CREATE TYPE person_type AS (id int, name text);
CREATE TABLE persons OF person_type;
INSERT INTO persons VALUES (1, 'test');
-CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$;
+CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQLTEST AS $$ SELECT length($1.name) $$;
SELECT id, namelen(persons) FROM persons;
id | namelen
----+---------
diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out
index 24905332b1..0380b393b7 100644
--- a/src/test/regress/expected/updatable_views.out
+++ b/src/test/regress/expected/updatable_views.out
@@ -944,7 +944,7 @@ CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified');
INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i);
CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl;
CREATE FUNCTION rw_view1_aa(x rw_view1)
- RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql;
+ RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sqltest;
UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2
RETURNING rw_view1_aa(v), v.bb;
rw_view1_aa | bb
diff --git a/src/test/regress/expected/vacuum.out b/src/test/regress/expected/vacuum.out
index 3fccb183c0..98f36f3a2c 100644
--- a/src/test/regress/expected/vacuum.out
+++ b/src/test/regress/expected/vacuum.out
@@ -61,9 +61,9 @@ VACUUM (ANALYZE, FULL) vactst;
CREATE TABLE vaccluster (i INT PRIMARY KEY);
ALTER TABLE vaccluster CLUSTER ON vaccluster_pkey;
CLUSTER vaccluster;
-CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL
+CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQLTEST
AS 'ANALYZE pg_am';
-CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL
+CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQLTEST
AS 'SELECT $1 FROM do_analyze()';
CREATE INDEX ON vaccluster(wrap_do_analyze(i));
INSERT INTO vaccluster VALUES (1), (2);
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out
index 19e2ac518a..c3a344c780 100644
--- a/src/test/regress/expected/window.out
+++ b/src/test/regress/expected/window.out
@@ -3318,13 +3318,13 @@ SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four
-- intentionally not true inverses)
CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE AGGREGATE logging_agg_nonstrict (anyelement)
(
stype = text,
@@ -3345,13 +3345,13 @@ CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement)
);
CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '*' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '+' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE AGGREGATE logging_agg_strict (text)
(
stype = text,
@@ -3501,7 +3501,7 @@ ORDER BY i;
-- that one aggregate restarting doesn't cause others to restart.
CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS
$$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$
-LANGUAGE SQL STRICT;
+LANGUAGE SQLTEST STRICT;
CREATE AGGREGATE sum_int_randomrestart (int4)
(
stype = int4,
@@ -4042,7 +4042,7 @@ AS $$
SELECT array_agg(s) OVER w
FROM generate_series(1,5) s
WINDOW w AS (ORDER BY s ROWS BETWEEN CURRENT ROW AND GROUP_SIZE FOLLOWING)
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQLTEST STABLE;
EXPLAIN (costs off) SELECT * FROM pg_temp.f(2);
QUERY PLAN
------------------------------------------------------
diff --git a/src/test/regress/input/create_function_1.source b/src/test/regress/input/create_function_1.source
index 412e339fcf..c83845b8fe 100644
--- a/src/test/regress/input/create_function_1.source
+++ b/src/test/regress/input/create_function_1.source
@@ -80,19 +80,19 @@ CREATE FUNCTION test_opclass_options_func(internal)
-- Things that shouldn't work:
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT ''not an integer'';';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'not even SQL';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT 1, 2, 3;';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT $2;';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'a', 'b';
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
diff --git a/src/test/regress/input/create_function_2.source b/src/test/regress/input/create_function_2.source
index 9e6d2942ec..2af7dcaaf7 100644
--- a/src/test/regress/input/create_function_2.source
+++ b/src/test/regress/input/create_function_2.source
@@ -4,62 +4,62 @@
CREATE FUNCTION hobbies(person)
RETURNS setof hobbies_r
AS 'select * from hobbies_r where person = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct(text, text)
RETURNS hobbies_r
AS 'select $1 as name, $2 as hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct_named(name text, hobby text)
RETURNS hobbies_r
AS 'select name, hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE)
RETURNS hobbies_r.person%TYPE
AS 'select person from hobbies_r where name = $1'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment(hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = equipment_named.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1a(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_1a.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1b(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1c(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2a(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_2a.hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2b(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION pt_in_widget(point, widget)
diff --git a/src/test/regress/output/create_function_1.source b/src/test/regress/output/create_function_1.source
index 4d78fa1228..5d3a606f47 100644
--- a/src/test/regress/output/create_function_1.source
+++ b/src/test/regress/output/create_function_1.source
@@ -69,27 +69,27 @@ CREATE FUNCTION test_opclass_options_func(internal)
AS '@libdir@/regress@DLSUFFIX@', 'test_opclass_options_func'
LANGUAGE C;
-- Things that shouldn't work:
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT ''not an integer'';';
ERROR: return type mismatch in function declared to return integer
DETAIL: Actual return type is text.
CONTEXT: SQL function "test1"
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'not even SQL';
ERROR: syntax error at or near "not"
LINE 2: AS 'not even SQL';
^
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT 1, 2, 3;';
ERROR: return type mismatch in function declared to return integer
DETAIL: Final statement must return exactly one column.
CONTEXT: SQL function "test1"
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT $2;';
ERROR: there is no parameter $2
LINE 2: AS 'SELECT $2;';
^
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'a', 'b';
ERROR: only one AS item needed for language "sql"
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
diff --git a/src/test/regress/output/create_function_2.source b/src/test/regress/output/create_function_2.source
index ac9a7f5cf8..d98de86161 100644
--- a/src/test/regress/output/create_function_2.source
+++ b/src/test/regress/output/create_function_2.source
@@ -4,49 +4,49 @@
CREATE FUNCTION hobbies(person)
RETURNS setof hobbies_r
AS 'select * from hobbies_r where person = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct(text, text)
RETURNS hobbies_r
AS 'select $1 as name, $2 as hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct_named(name text, hobby text)
RETURNS hobbies_r
AS 'select name, hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE)
RETURNS hobbies_r.person%TYPE
AS 'select person from hobbies_r where name = $1'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
NOTICE: type reference hobbies_r.name%TYPE converted to text
NOTICE: type reference hobbies_r.person%TYPE converted to text
CREATE FUNCTION equipment(hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = equipment_named.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1a(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_1a.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1b(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1c(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2a(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_2a.hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2b(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION pt_in_widget(point, widget)
RETURNS bool
AS '@libdir@/regress@DLSUFFIX@'
diff --git a/src/test/regress/sql/alter_generic.sql b/src/test/regress/sql/alter_generic.sql
index 8c5d0e5e1f..75fa8f6b6e 100644
--- a/src/test/regress/sql/alter_generic.sql
+++ b/src/test/regress/sql/alter_generic.sql
@@ -26,9 +26,9 @@ SET search_path = alt_nsp1, public;
-- Function and Aggregate
--
SET SESSION AUTHORIZATION regress_alter_generic_user1;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 1';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 1';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0
@@ -54,9 +54,9 @@ ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3; -- OK
ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2; -- OK
SET SESSION AUTHORIZATION regress_alter_generic_user2;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 2';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 2';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100
@@ -354,7 +354,7 @@ DROP OPERATOR FAMILY alt_opf11 USING gist;
-- Should fail. btree comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf12 USING btree;
-CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2);
DROP OPERATOR FAMILY alt_opf12 USING btree;
ROLLBACK;
@@ -362,7 +362,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf13 USING hash;
-CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4);
DROP OPERATOR FAMILY alt_opf13 USING hash;
ROLLBACK;
@@ -370,7 +370,7 @@ ROLLBACK;
-- Should fail. btree comparison functions should have two arguments in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf14 USING btree;
-CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4);
DROP OPERATOR FAMILY alt_opf14 USING btree;
ROLLBACK;
@@ -378,7 +378,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should have one argument in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf15 USING hash;
-CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2);
DROP OPERATOR FAMILY alt_opf15 USING hash;
ROLLBACK;
diff --git a/src/test/regress/sql/alter_operator.sql b/src/test/regress/sql/alter_operator.sql
index fd40370165..91f4a2c187 100644
--- a/src/test/regress/sql/alter_operator.sql
+++ b/src/test/regress/sql/alter_operator.sql
@@ -1,5 +1,5 @@
CREATE FUNCTION alter_op_test_fn(boolean, boolean)
-RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
+RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sqltest IMMUTABLE;
CREATE FUNCTION customcontsel(internal, oid, internal, integer)
RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT;
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 4cc55d8525..4e5af2014c 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -1798,14 +1798,14 @@ drop type lockmodes;
--
create function test_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql returns null on null input;
+ LANGUAGE SQLTEST returns null on null input;
select test_strict(NULL);
alter function test_strict(text) called on null input;
select test_strict(NULL);
create function non_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql called on null input;
+ LANGUAGE SQLTEST called on null input;
select non_strict(NULL);
alter function non_strict(text) returns null on null input;
select non_strict(NULL);
@@ -1821,13 +1821,13 @@ create table alter1.t1(f1 serial primary key, f2 int check (f2 > 0));
create view alter1.v1 as select * from alter1.t1;
-create function alter1.plus1(int) returns int as 'select $1+1' language sql;
+create function alter1.plus1(int) returns int as 'select $1+1' LANGUAGE SQLTEST;
create domain alter1.posint integer check (value > 0);
create type alter1.ctype as (f1 int, f2 text);
-create function alter1.same(alter1.ctype, alter1.ctype) returns boolean language sql
+create function alter1.same(alter1.ctype, alter1.ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
create operator alter1.=(procedure = alter1.same, leftarg = alter1.ctype, rightarg = alter1.ctype);
@@ -2838,7 +2838,7 @@ drop function func_part_attach();
-- test case where the partitioning operator is a SQL function whose
-- evaluation results in the table's relcache being rebuilt partway through
-- the execution of an ATTACH PARTITION command
-create function at_test_sql_partop (int4, int4) returns int language sql
+create function at_test_sql_partop (int4, int4) returns int LANGUAGE SQLTEST
as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$;
create operator class at_test_sql_partop for type int4 using btree as
operator 1 < (int4, int4), operator 2 <= (int4, int4),
diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql
index c40619a8d5..ca9cfd41da 100644
--- a/src/test/regress/sql/arrays.sql
+++ b/src/test/regress/sql/arrays.sql
@@ -499,13 +499,13 @@ drop type comptype;
create or replace function unnest1(anyarray)
returns setof anyelement as $$
select $1[s] from generate_subscripts($1,1) g(s);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create or replace function unnest2(anyarray)
returns setof anyelement as $$
select $1[s1][s2] from generate_subscripts($1,1) g1(s1),
generate_subscripts($1,2) g2(s2);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select * from unnest1(array[1,2,3]);
select * from unnest2(array[[1,2,3],[4,5,6]]);
diff --git a/src/test/regress/sql/case.sql b/src/test/regress/sql/case.sql
index 0655d266f6..dce020ea2f 100644
--- a/src/test/regress/sql/case.sql
+++ b/src/test/regress/sql/case.sql
@@ -196,7 +196,7 @@ CREATE FUNCTION volfoo(text) returns foodomain as
'begin return $1::foodomain; end' language plpgsql volatile;
CREATE FUNCTION inline_eq(foodomain, foodomain) returns boolean as
- 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' language sql;
+ 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' LANGUAGE SQLTEST;
CREATE OPERATOR = (procedure = inline_eq,
leftarg = foodomain, rightarg = foodomain);
diff --git a/src/test/regress/sql/collate.icu.utf8.sql b/src/test/regress/sql/collate.icu.utf8.sql
index 0de2ed8d85..d4d3a6d8be 100644
--- a/src/test/regress/sql/collate.icu.utf8.sql
+++ b/src/test/regress/sql/collate.icu.utf8.sql
@@ -266,10 +266,10 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
@@ -322,7 +322,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER
SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1;
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
diff --git a/src/test/regress/sql/collate.linux.utf8.sql b/src/test/regress/sql/collate.linux.utf8.sql
index c697c99488..6767fc9379 100644
--- a/src/test/regress/sql/collate.linux.utf8.sql
+++ b/src/test/regress/sql/collate.linux.utf8.sql
@@ -274,10 +274,10 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
@@ -330,7 +330,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER
SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1;
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
diff --git a/src/test/regress/sql/collate.sql b/src/test/regress/sql/collate.sql
index 82f9c855b8..f518856165 100644
--- a/src/test/regress/sql/collate.sql
+++ b/src/test/regress/sql/collate.sql
@@ -179,7 +179,7 @@ SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2;
-- result of a SQL function
-CREATE FUNCTION vc (text) RETURNS text LANGUAGE sql
+CREATE FUNCTION vc (text) RETURNS text LANGUAGE sqltest
AS 'select $1::varchar';
SELECT a, b FROM collate_test1 ORDER BY a, vc(b);
@@ -191,7 +191,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER
SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1;
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
diff --git a/src/test/regress/sql/create_aggregate.sql b/src/test/regress/sql/create_aggregate.sql
index d4b4036fd7..69b1b97511 100644
--- a/src/test/regress/sql/create_aggregate.sql
+++ b/src/test/regress/sql/create_aggregate.sql
@@ -44,7 +44,7 @@ COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment';
-- multi-argument aggregate
create function sum3(int8,int8,int8) returns int8 as
-'select $1 + $2 + $3' language sql strict immutable;
+'select $1 + $2 + $3' LANGUAGE SQLTEST strict immutable;
create aggregate sum2(int8,int8) (
sfunc = sum3, stype = int8,
@@ -56,11 +56,11 @@ create type aggtype as (a integer, b integer, c text);
create function aggf_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql strict immutable;
+LANGUAGE SQLTEST strict immutable;
create function aggfns_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql immutable;
+LANGUAGE SQLTEST immutable;
create aggregate aggfstr(integer,integer,text) (
sfunc = aggf_trans, stype = aggtype[],
@@ -73,7 +73,7 @@ create aggregate aggfns(integer,integer,text) (
);
-- check error cases that would require run-time type coercion
-create function least_accum(int8, int8) returns int8 language sql as
+create function least_accum(int8, int8) returns int8 LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
@@ -83,7 +83,7 @@ create aggregate least_agg(int4) (
drop function least_accum(int8, int8);
create function least_accum(anycompatible, anycompatible)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
@@ -98,7 +98,7 @@ drop function least_accum(anycompatible, anycompatible) cascade;
-- variadic aggregates
create function least_accum(anyelement, variadic anyarray)
-returns anyelement language sql as
+returns anyelement LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate least_agg(variadic items anyarray) (
@@ -106,7 +106,7 @@ create aggregate least_agg(variadic items anyarray) (
);
create function cleast_accum(anycompatible, variadic anycompatiblearray)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate cleast_agg(variadic items anycompatiblearray) (
@@ -259,7 +259,7 @@ CREATE OR REPLACE AGGREGATE myavg (order by numeric)
-- can't change plain function to aggregate:
create function sum4(int8,int8,int8,int8) returns int8 as
-'select $1 + $2 + $3 + $4' language sql strict immutable;
+'select $1 + $2 + $3 + $4' LANGUAGE SQLTEST strict immutable;
CREATE OR REPLACE AGGREGATE sum3 (int8,int8,int8)
(
@@ -283,7 +283,7 @@ CREATE AGGREGATE mysum (int)
CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS
$$ SELECT $1 - $2; $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE invalidsumdouble (float8)
(
@@ -298,7 +298,7 @@ CREATE AGGREGATE invalidsumdouble (float8)
CREATE FUNCTION float8mi_int(float8, float8) RETURNS int AS
$$ SELECT CAST($1 - $2 AS INT); $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE wrongreturntype (float8)
(
diff --git a/src/test/regress/sql/create_cast.sql b/src/test/regress/sql/create_cast.sql
index b11cf88b06..219edd67fc 100644
--- a/src/test/regress/sql/create_cast.sql
+++ b/src/test/regress/sql/create_cast.sql
@@ -22,7 +22,7 @@ CREATE TYPE casttesttype (
);
-- a dummy function to test with
-CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQL AS
+CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQLTEST AS
$$ SELECT 1; $$;
SELECT casttestfunc('foo'::text); -- fails, as there's no cast
@@ -47,7 +47,7 @@ DROP CAST (int4 AS casttesttype);
-- Try cast with a function
-CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQL AS
+CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQLTEST AS
$$ SELECT ('foo'::text || $1::text)::casttesttype; $$;
CREATE CAST (int4 AS casttesttype) WITH FUNCTION int4_casttesttype(int4) AS IMPLICIT;
diff --git a/src/test/regress/sql/create_function_3.sql b/src/test/regress/sql/create_function_3.sql
index bd108a918f..c404f38f7d 100644
--- a/src/test/regress/sql/create_function_3.sql
+++ b/src/test/regress/sql/create_function_3.sql
@@ -20,11 +20,11 @@ SET search_path TO temp_func_test, public;
--
-- ARGUMENT and RETURN TYPES
--
-CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
-CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
+CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sqltest'
AS 'SELECT $1[1]::int';
-CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT false';
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
WHERE oid in ('functest_A_1'::regproc,
@@ -38,13 +38,13 @@ SELECT functest_A_3();
--
-- IMMUTABLE | STABLE | VOLATILE
--
-CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sqltest'
STABLE AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sqltest'
VOLATILE AS 'SELECT $1 < 0';
SELECT proname, provolatile FROM pg_proc
WHERE oid in ('functest_B_1'::regproc,
@@ -63,11 +63,11 @@ SELECT proname, provolatile FROM pg_proc
--
-- SECURITY DEFINER | INVOKER
--
-CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY DEFINER AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY INVOKER AS 'SELECT $1 < 0';
SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functest_C_1'::regproc,
@@ -85,9 +85,9 @@ SELECT proname, prosecdef FROM pg_proc
--
-- LEAKPROOF
--
-CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 100';
-CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 > 100';
SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functest_E_1'::regproc,
@@ -113,7 +113,7 @@ SET search_path TO temp_func_test, public;
ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF;
ALTER FUNCTION functest_E_2(int) LEAKPROOF;
-CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 < 200'; -- fail
RESET SESSION AUTHORIZATION;
@@ -121,13 +121,13 @@ RESET SESSION AUTHORIZATION;
--
-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
--
-CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 50';
-CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sqltest'
CALLED ON NULL INPUT AS 'SELECT $1 = 50';
-CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sqltest'
RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50';
-CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sqltest'
STRICT AS 'SELECT $1 = 50';
SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functest_F_1'::regproc,
@@ -157,17 +157,17 @@ SELECT pg_get_functiondef('functest_F_2'::regproc);
CREATE FUNCTION functest_IS_1(a int, b int default 1, c text default 'foo')
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1 + $2';
CREATE FUNCTION functest_IS_2(out a int, b int default 1)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
CREATE FUNCTION functest_IS_3(a int default 1, out b int)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
SELECT routine_name, ordinal_position, parameter_name, parameter_default
@@ -178,7 +178,7 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
-- overload
-CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
DROP FUNCTION functest_b_1;
@@ -188,19 +188,19 @@ DROP FUNCTION functest_b_2; -- error, ambiguous
-- CREATE OR REPLACE tests
-CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL AS 'SELECT $1';
-CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL WINDOW AS 'SELECT $1';
-CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQL AS 'SELECT $1';
+CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST AS 'SELECT $1';
+CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST WINDOW AS 'SELECT $1';
+CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQLTEST AS 'SELECT $1';
DROP FUNCTION functest1(a int);
-- Check behavior of VOID-returning SQL functions
-CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT a + 1 $$;
SELECT voidtest1(42);
-CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT voidtest1(a + b) $$;
SELECT voidtest2(11,22);
@@ -209,17 +209,17 @@ EXPLAIN (verbose, costs off) SELECT voidtest2(11,22);
CREATE TEMP TABLE sometable(f1 int);
-CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a + 1) $$;
SELECT voidtest3(17);
-CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a - 1) RETURNING f1 $$;
SELECT voidtest4(39);
TABLE sometable;
-CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQLTEST AS
$$ SELECT generate_series(1, a) $$ STABLE;
SELECT * FROM voidtest5(3);
diff --git a/src/test/regress/sql/create_operator.sql b/src/test/regress/sql/create_operator.sql
index 4ff2c0ff21..ebf1eddab7 100644
--- a/src/test/regress/sql/create_operator.sql
+++ b/src/test/regress/sql/create_operator.sql
@@ -117,7 +117,7 @@ BEGIN TRANSACTION;
CREATE OR REPLACE FUNCTION fn_op2(boolean, boolean)
RETURNS boolean AS $$
SELECT NULL::BOOLEAN;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
CREATE OPERATOR === (
LEFTARG = boolean,
RIGHTARG = boolean,
@@ -154,7 +154,7 @@ CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op3(type_op3, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op3 FROM regress_rol_op3;
REVOKE USAGE ON TYPE type_op3 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op3;
@@ -172,7 +172,7 @@ CREATE TYPE type_op4 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op4(int8, type_op4)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op4 FROM regress_rol_op4;
REVOKE USAGE ON TYPE type_op4 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op4;
@@ -190,7 +190,7 @@ CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op5(int8, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM PUBLIC;-- Need to do this so that regress_rol_op3 is not allowed EXECUTE via PUBLIC
SET ROLE regress_rol_op5;
@@ -208,7 +208,7 @@ CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op6(int8, int8)
RETURNS type_op6 AS $$
SELECT NULL::type_op6;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op6 FROM regress_rol_op6;
REVOKE USAGE ON TYPE type_op6 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op6;
diff --git a/src/test/regress/sql/create_procedure.sql b/src/test/regress/sql/create_procedure.sql
index 2ef1c82cea..110ce78891 100644
--- a/src/test/regress/sql/create_procedure.sql
+++ b/src/test/regress/sql/create_procedure.sql
@@ -1,12 +1,12 @@
CALL nonexistent(); -- error
CALL random(); -- error
-CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQL AS $$ SELECT a $$;
+CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQLTEST AS $$ SELECT a $$;
CREATE TABLE cp_test (a int, b text);
CREATE PROCEDURE ptest1(x text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, x);
$$;
@@ -29,7 +29,7 @@ SELECT * FROM cp_test ORDER BY b COLLATE "C";
CREATE PROCEDURE ptest2()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 5;
$$;
@@ -41,7 +41,7 @@ CALL ptest2();
TRUNCATE cp_test;
CREATE PROCEDURE ptest3(y text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest1(y);
CALL ptest1($1);
@@ -55,7 +55,7 @@ SELECT * FROM cp_test;
-- output arguments
CREATE PROCEDURE ptest4a(INOUT a int, INOUT b int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 1, 2;
$$;
@@ -63,7 +63,7 @@ $$;
CALL ptest4a(NULL, NULL);
CREATE PROCEDURE ptest4b(INOUT b int, INOUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest4a(a, b); -- error, not supported
$$;
@@ -74,7 +74,7 @@ DROP PROCEDURE ptest4a;
-- named and default parameters
CREATE OR REPLACE PROCEDURE ptest5(a int, b text, c int default 100)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES(a, b);
INSERT INTO cp_test VALUES(c, b);
@@ -93,7 +93,7 @@ SELECT * FROM cp_test;
-- polymorphic types
CREATE PROCEDURE ptest6(a int, b anyelement)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT NULL::int;
$$;
@@ -104,7 +104,7 @@ CALL ptest6(1, 2);
-- collation assignment
CREATE PROCEDURE ptest7(a text, b text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT a = b;
$$;
@@ -115,7 +115,7 @@ CALL ptest7(least('a', 'b'), 'a');
-- OUT parameters
CREATE PROCEDURE ptest9(OUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, 'a');
SELECT 1;
@@ -129,8 +129,8 @@ CALL ptest9(NULL);
CALL version(); -- error: not a procedure
CALL sum(1); -- error: not a procedure
-CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
-CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
ALTER PROCEDURE ptest1(text) STRICT;
ALTER FUNCTION ptest1(text) VOLATILE; -- error: not a function
diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql
index d257679ba6..048d10a50e 100644
--- a/src/test/regress/sql/create_table.sql
+++ b/src/test/regress/sql/create_table.sql
@@ -355,7 +355,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a);
-- prevent using prohibited expressions in the key
-CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (retset(a));
@@ -378,7 +378,7 @@ CREATE TABLE partitioned (
a int
) PARTITION BY RANGE ((42));
-CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (const_func());
@@ -410,7 +410,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a, ('unknown'));
-- functions in key must be immutable
-CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL;
+CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (immut_func(a));
@@ -437,7 +437,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a);
-- some checks after successful creation of a partitioned table
-CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL;
+CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int,
@@ -866,7 +866,7 @@ CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, M
DROP TABLE range_parted4;
-- user-defined operator class in partition key
-CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql
+CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sqltest
AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$;
CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS
OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4),
diff --git a/src/test/regress/sql/create_type.sql b/src/test/regress/sql/create_type.sql
index a32a9e6795..e0eda962b7 100644
--- a/src/test/regress/sql/create_type.sql
+++ b/src/test/regress/sql/create_type.sql
@@ -117,7 +117,7 @@ CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42);
CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS '
SELECT * FROM default_test;
-' LANGUAGE SQL;
+' LANGUAGE SQLTEST;
SELECT * FROM get_default_test();
diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql
index 549c0b5adf..bd0438dc3e 100644
--- a/src/test/regress/sql/domain.sql
+++ b/src/test/regress/sql/domain.sql
@@ -724,7 +724,7 @@ drop domain di;
--
create function sql_is_distinct_from(anyelement, anyelement)
-returns boolean language sql
+returns boolean LANGUAGE SQLTEST
as 'select $1 is distinct from $2 limit 1';
create domain inotnull int
diff --git a/src/test/regress/sql/drop_if_exists.sql b/src/test/regress/sql/drop_if_exists.sql
index ac6168b91f..020d32d00f 100644
--- a/src/test/regress/sql/drop_if_exists.sql
+++ b/src/test/regress/sql/drop_if_exists.sql
@@ -274,8 +274,8 @@ DROP VIEW IF EXISTS no_such_schema.foo;
-- Check we receive an ambiguous function error when there are
-- multiple matching functions.
-CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ language sql;
-CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ language sql;
+CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ LANGUAGE SQLTEST;
+CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ LANGUAGE SQLTEST;
DROP FUNCTION test_ambiguous_funcname;
DROP FUNCTION IF EXISTS test_ambiguous_funcname;
diff --git a/src/test/regress/sql/event_trigger.sql b/src/test/regress/sql/event_trigger.sql
index 18b2a267cb..ae028331c1 100644
--- a/src/test/regress/sql/event_trigger.sql
+++ b/src/test/regress/sql/event_trigger.sql
@@ -19,7 +19,7 @@ returns event_trigger as $$ BEGIN RETURN 1; END $$ language plpgsql;
-- should fail, SQL functions cannot be event triggers
create function test_event_trigger_sql() returns event_trigger as $$
-SELECT 1 $$ language sql;
+SELECT 1 $$ LANGUAGE SQLTEST;
-- should fail, no elephant_bootstrap entry point
create event trigger regress_event_trigger on elephant_bootstrap
diff --git a/src/test/regress/sql/foreign_data.sql b/src/test/regress/sql/foreign_data.sql
index 73f9f621d8..437bd1be27 100644
--- a/src/test/regress/sql/foreign_data.sql
+++ b/src/test/regress/sql/foreign_data.sql
@@ -52,7 +52,7 @@ CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator;
\dew+
-- HANDLER related checks
-CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;';
+CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQLTEST AS 'SELECT 1;';
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler; -- ERROR
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler;
diff --git a/src/test/regress/sql/generated.sql b/src/test/regress/sql/generated.sql
index bd2b0bfaaa..49fa1da9c7 100644
--- a/src/test/regress/sql/generated.sql
+++ b/src/test/regress/sql/generated.sql
@@ -226,7 +226,7 @@ CREATE TABLE gtest11s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (b *
INSERT INTO gtest11s VALUES (1, 10), (2, 20);
GRANT SELECT (a, c) ON gtest11s TO regress_user11;
-CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQL;
+CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQLTEST;
REVOKE ALL ON FUNCTION gf1(int) FROM PUBLIC;
CREATE TABLE gtest12s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (gf1(b)) STORED);
diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql
index 43dbba3775..ec986f226c 100644
--- a/src/test/regress/sql/guc.sql
+++ b/src/test/regress/sql/guc.sql
@@ -205,7 +205,7 @@ reset search_path;
set work_mem = '3MB';
create function report_guc(text) returns text as
-$$ select current_setting($1) $$ language sql
+$$ select current_setting($1) $$ LANGUAGE SQLTEST
set work_mem = '1MB';
select report_guc('work_mem'), current_setting('work_mem');
@@ -280,13 +280,13 @@ select current_setting('nosuch.setting', true);
-- because that creates ordering hazards for pg_dump
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
set check_function_bodies = off;
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
select func_with_bad_set();
diff --git a/src/test/regress/sql/infinite_recurse.sql b/src/test/regress/sql/infinite_recurse.sql
index 151dba4a7a..c3f4f3ae6d 100644
--- a/src/test/regress/sql/infinite_recurse.sql
+++ b/src/test/regress/sql/infinite_recurse.sql
@@ -2,7 +2,7 @@
-- max_stack_depth is not set too high.
create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
+'select infinite_recurse()' LANGUAGE SQLTEST;
-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
-- signal handling that would cause this test to crash if it happened
diff --git a/src/test/regress/sql/inherit.sql b/src/test/regress/sql/inherit.sql
index 64173a8738..fe1cb7775c 100644
--- a/src/test/regress/sql/inherit.sql
+++ b/src/test/regress/sql/inherit.sql
@@ -251,7 +251,7 @@ drop table base;
create table p1(ff1 int);
create table p2(f1 text);
-create function p2text(p2) returns text as 'select $1.f1' language sql;
+create function p2text(p2) returns text as 'select $1.f1' LANGUAGE SQLTEST;
create table c1(f3 int) inherits(p1,p2);
insert into c1 values(123456789, 'hi', 42);
select p2text(c1.*) from c1;
diff --git a/src/test/regress/sql/insert.sql b/src/test/regress/sql/insert.sql
index 963faa1614..06cad2c9f5 100644
--- a/src/test/regress/sql/insert.sql
+++ b/src/test/regress/sql/insert.sql
@@ -236,7 +236,7 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
create or replace function part_hashint4_noop(value int4, seed int8)
returns int8 as $$
select value + seed;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_int4_ops
for type int4
@@ -247,7 +247,7 @@ function 2 part_hashint4_noop(int4, int8);
create or replace function part_hashtext_length(value text, seed int8)
RETURNS int8 AS $$
select length(coalesce(value, ''))::int8
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_text_ops
for type text
diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql
index 9887fe0c0b..555302e841 100644
--- a/src/test/regress/sql/join.sql
+++ b/src/test/regress/sql/join.sql
@@ -1135,10 +1135,10 @@ drop function f_immutable_int4(int);
-- test inlining when function returns composite
create function mki8(bigint, bigint) returns int8_tbl as
-$$select row($1,$2)::int8_tbl$$ language sql;
+$$select row($1,$2)::int8_tbl$$ LANGUAGE SQLTEST;
create function mki4(int) returns int4_tbl as
-$$select row($1)::int4_tbl$$ language sql;
+$$select row($1)::int4_tbl$$ LANGUAGE SQLTEST;
explain (verbose, costs off)
select * from mki8(1,2);
diff --git a/src/test/regress/sql/multirangetypes.sql b/src/test/regress/sql/multirangetypes.sql
index 692f2416d9..176812969d 100644
--- a/src/test/regress/sql/multirangetypes.sql
+++ b/src/test/regress/sql/multirangetypes.sql
@@ -630,7 +630,7 @@ drop type textrange2;
--
create function anyarray_anymultirange_func(a anyarray, r anymultirange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anymultirange_func(ARRAY[1,2], int4multirange(int4range(10,20)));
@@ -641,27 +641,27 @@ drop function anyarray_anymultirange_func(anyarray, anymultirange);
-- should fail
create function bogus_func(anyelement)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
-- should fail
create function bogus_func(int)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
create function range_add_bounds(anymultirange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4multirange(int4range(1, 17)));
select range_add_bounds(nummultirange(numrange(1.0001, 123.123)));
create function multirangetypes_sql(q anymultirange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select multirangetypes_sql(int4multirange(int4range(1,10)), ARRAY[2,20]);
select multirangetypes_sql(nummultirange(numrange(1,10)), ARRAY[2,20]); -- match failure
create function anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompatiblemultirange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(int4range(10,20)));
@@ -673,7 +673,7 @@ select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1.1,2], multirange(
drop function anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemultirange);
create function anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompatiblemultirange)
- returns anycompatible as 'select lower($1) + lower($2);' language sql;
+ returns anycompatible as 'select lower($1) + lower($2);' LANGUAGE SQLTEST;
select anycompatiblerange_anycompatiblemultirange_func(int4range(1,2), multirange(int4range(10,20)));
@@ -684,7 +684,7 @@ drop function anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
--
-- Arrays of multiranges
@@ -737,36 +737,36 @@ reset enable_sort;
-- infer anymultirange from anymultirange
create function mr_outparam_succeed(i anymultirange, out r anymultirange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed(int4multirange(int4range(1,2)));
-- infer anyarray from anymultirange
create function mr_outparam_succeed2(i anymultirange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed2(int4multirange(int4range(1,2)));
-- infer anyrange from anymultirange
create function mr_outparam_succeed3(i anymultirange, out r anyrange, out t text)
- as $$ select range_merge($1), 'foo'::text $$ language sql;
+ as $$ select range_merge($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed3(int4multirange(int4range(1,2)));
-- infer anymultirange from anyrange
create function mr_outparam_succeed4(i anyrange, out r anymultirange, out t text)
- as $$ select multirange($1), 'foo'::text $$ language sql;
+ as $$ select multirange($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed4(int4range(1,2));
-- infer anyelement from anymultirange
create function mr_inoutparam_succeed(out i anyelement, inout r anymultirange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from mr_inoutparam_succeed(int4multirange(int4range(1,2)));
-- infer anyelement+anymultirange from anyelement+anymultirange
create function mr_table_succeed(i anyelement, r anymultirange) returns table(i anyelement, r anymultirange)
- as $$ select $1, $2 $$ language sql;
+ as $$ select $1, $2 $$ LANGUAGE SQLTEST;
select * from mr_table_succeed(123, int4multirange(int4range(1,11)));
@@ -777,12 +777,12 @@ select mr_polymorphic(int4range(1, 4));
-- should fail
create function mr_outparam_fail(i anyelement, out r anymultirange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
--should fail
create function mr_inoutparam_fail(inout i anyelement, out r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
--should fail
create function mr_table_fail(i anyelement) returns table(i anyelement, r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
diff --git a/src/test/regress/sql/object_address.sql b/src/test/regress/sql/object_address.sql
index 2f4f66e3e1..7926fb77c6 100644
--- a/src/test/regress/sql/object_address.sql
+++ b/src/test/regress/sql/object_address.sql
@@ -35,14 +35,14 @@ CREATE DOMAIN addr_nsp.gendomain AS int4 CONSTRAINT domconstr CHECK (value > 0);
CREATE FUNCTION addr_nsp.trig() RETURNS TRIGGER LANGUAGE plpgsql AS $$ BEGIN END; $$;
CREATE TRIGGER t BEFORE INSERT ON addr_nsp.gentable FOR EACH ROW EXECUTE PROCEDURE addr_nsp.trig();
CREATE POLICY genpol ON addr_nsp.gentable;
-CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQL AS $$ $$;
+CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQLTEST AS $$ $$;
CREATE SERVER "integer" FOREIGN DATA WRAPPER addr_fdw;
CREATE USER MAPPING FOR regress_addr_user SERVER "integer";
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regress_addr_user;
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM regress_addr_user;
-- this transform would be quite unsafe to leave lying around,
-- except that the SQL language pays no attention to transforms:
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
-- suppress warning that depends on wal_level
@@ -271,7 +271,7 @@ WITH objects (classid, objid, objsubid) AS (VALUES
('pg_policy'::regclass, 0, 0), -- no policy
('pg_publication'::regclass, 0, 0), -- no publication
('pg_publication_rel'::regclass, 0, 0), -- no publication relation
- ('pg_subscription'::regclass, 0, 0), -- no subscription
+ ('pg_sub'::regclass, 0, 0), -- no subscription
('pg_transform'::regclass, 0, 0) -- no transformation
)
SELECT ROW(pg_identify_object(objects.classid, objects.objid, objects.objsubid))
diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql
index 781666a83a..2d1bb17554 100644
--- a/src/test/regress/sql/plpgsql.sql
+++ b/src/test/regress/sql/plpgsql.sql
@@ -3610,11 +3610,11 @@ $$ language plpgsql;
-- "limit" is to prevent this from being inlined
create function sql_recurse(float8) returns float8 as
-$$ select recurse($1) limit 1; $$ language sql;
+$$ select recurse($1) limit 1; $$ LANGUAGE SQLTEST;
select recurse(10);
-create function error1(text) returns text language sql as
+create function error1(text) returns text LANGUAGE SQLTEST as
$$ SELECT relname::text FROM pg_class c WHERE c.oid = $1::regclass $$;
create function error2(p_name_table text) returns text language plpgsql as $$
@@ -3637,7 +3637,7 @@ drop function error1(text);
create function sql_to_date(integer) returns date as $$
select $1::text::date
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
create cast (integer as date) with function sql_to_date(integer) as assignment;
diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/polymorphism.sql
index 891b023ada..5529f99671 100644
--- a/src/test/regress/sql/polymorphism.sql
+++ b/src/test/regress/sql/polymorphism.sql
@@ -5,7 +5,7 @@
create function polyf(x anyelement) returns anyelement as $$
select x + 1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
select polyf(point(3,4)); -- fail for lack of + operator
@@ -14,7 +14,7 @@ drop function polyf(x anyelement);
create function polyf(x anyelement) returns anyarray as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
@@ -22,7 +22,7 @@ drop function polyf(x anyelement);
create function polyf(x anyarray) returns anyelement as $$
select x[1]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
@@ -32,7 +32,7 @@ drop function polyf(x anyarray);
create function polyf(x anyarray) returns anyarray as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
@@ -43,11 +43,11 @@ drop function polyf(x anyarray);
-- fail, can't infer type:
create function polyf(x anyelement) returns anyrange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function polyf(x anyrange) returns anyarray as $$
select array[lower(x), upper(x)]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num;
@@ -55,7 +55,7 @@ drop function polyf(x anyrange);
create function polyf(x anycompatible, y anycompatible) returns anycompatiblearray as $$
select array[x, y]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(2, 4) as int, polyf(2, 4.5) as num;
@@ -63,7 +63,7 @@ drop function polyf(x anycompatible, y anycompatible);
create function polyf(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), 11, 2::smallint) as int, polyf(float8range(4.5, 7.8), 7.8, 11::real) as num;
@@ -73,7 +73,7 @@ drop function polyf(x anycompatiblerange, y anycompatible, z anycompatible);
create function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), 11, 2::smallint) as int, polyf(multirange(float8range(4.5, 7.8)), 7.8, 11::real) as num;
@@ -84,11 +84,11 @@ drop function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible)
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblerange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function polyf(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), array[11]) as int, polyf(float8range(4.5, 7.8), array[7]) as num;
@@ -97,11 +97,11 @@ drop function polyf(x anycompatiblerange, y anycompatiblearray);
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblemultirange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function polyf(x anycompatiblemultirange, y anycompatiblearray) returns anycompatiblemultirange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), array[11]) as int, polyf(multirange(float8range(4.5, 7.8)), array[7]) as num;
@@ -112,7 +112,7 @@ create function polyf(a anyelement, b anyarray,
OUT x anyarray, OUT y anycompatiblearray)
as $$
select a || b, array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x), y, pg_typeof(y)
from polyf(11, array[1, 2], 42, 34.5);
@@ -166,35 +166,35 @@ drop function polyf(a anyelement, b anyarray,
-- polymorphic single arg transfn
CREATE FUNCTION stfp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- non-polymorphic single arg transfn
CREATE FUNCTION stfnp(int[]) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- dual polymorphic transfn
CREATE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- dual non-polymorphic transfn
CREATE FUNCTION tfnp(int[],int) RETURNS int[] AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- arg1 only polymorphic transfn
CREATE FUNCTION tf1p(anyarray,int) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- arg2 only polymorphic transfn
CREATE FUNCTION tf2p(int[],anyelement) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- multi-arg polymorphic
CREATE FUNCTION sum3(anyelement,anyelement,anyelement) returns anyelement AS
-'select $1+$2+$3' language sql strict;
+'select $1+$2+$3' LANGUAGE SQLTEST strict;
-- finalfn polymorphic
CREATE FUNCTION ffp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- finalfn non-polymorphic
CREATE FUNCTION ffnp(int[]) returns int[] as
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- Try to cover all the possible states:
--
@@ -511,7 +511,7 @@ begin
end$$ language plpgsql;
create function sql_if(bool, anyelement, anyelement) returns anyelement as $$
-select case when $1 then $2 else $3 end $$ language sql;
+select case when $1 then $2 else $3 end $$ LANGUAGE SQLTEST;
-- Note this would fail with integer overflow, never mind wrong bleat() output,
-- if the CASE expression were not successfully inlined
@@ -573,10 +573,10 @@ create aggregate build_group(int8, integer) (
-- check proper resolution of data types for polymorphic transfn/finalfn
create function first_el_transfn(anyarray, anyelement) returns anyarray as
-'select $1 || $2' language sql immutable;
+'select $1 || $2' LANGUAGE SQLTEST immutable;
create function first_el(anyarray) returns anyelement as
-'select $1[1]' language sql strict immutable;
+'select $1[1]' LANGUAGE SQLTEST strict immutable;
create aggregate first_el_agg_f8(float8) (
SFUNC = array_append,
@@ -612,7 +612,7 @@ select anyrange_in('[10,20)','int4range'::regtype,-1);
create function myleast(variadic anyarray) returns anyelement as $$
select min($1[i]) from generate_subscripts($1,1) g(i)
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select myleast(10, 1, 20, 33);
select myleast(1.1, 0.22, 0.55);
@@ -629,7 +629,7 @@ select myleast(variadic array[]::int[]);
-- an example with some ordinary arguments too
create function concat(text, variadic anyarray) returns text as $$
select array_to_string($2, $1);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select concat('%', 1, 2, 3, 4, 5);
select concat('|', 'a'::text, 'b', 'c');
@@ -641,7 +641,7 @@ drop function concat(text, anyarray);
-- mix variadic with anyelement
create function formarray(anyelement, variadic anyarray) returns anyarray as $$
select array_prepend($1, $2);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select formarray(1,2,3,4,5);
select formarray(1.1, variadic array[1.2,55.5]);
@@ -667,7 +667,7 @@ select pg_typeof(myleast(10, 1, 20, 33)); -- polymorphic input
-- test basic functionality
create function dfunc(a int = 1, int = 2) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
select dfunc(10);
@@ -681,12 +681,12 @@ drop function dfunc(int, int); -- ok
-- fail: defaults must be at end of argument list
create function dfunc(a int = 1, b int) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- however, this should work:
create function dfunc(a int = 1, out sum int, b int = 2) as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
@@ -698,12 +698,12 @@ drop function dfunc(int, int);
-- check implicit coercion
create function dfunc(a int DEFAULT 1.0, int DEFAULT '-1') returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
create function dfunc(a text DEFAULT 'Hello', b text DEFAULT 'World') returns text as $$
select $1 || ', ' || $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(); -- fail: which dfunc should be called? int or text
select dfunc('Hi'); -- ok
@@ -716,11 +716,11 @@ drop function dfunc(text, text);
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2, int = 3, int = 4) returns int as $$
select 4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- Now, dfunc(nargs = 2) and dfunc(nargs = 4) are ambiguous when called
-- with 0 to 2 arguments.
@@ -737,12 +737,12 @@ drop function dfunc(int, int, int, int);
-- default values are not allowed for output parameters
create function dfunc(out int = 20) returns int as $$
select 1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- polymorphic parameter test
create function dfunc(anyelement = 'World'::text) returns text as $$
select 'Hello, ' || $1::text;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
select dfunc(0);
@@ -754,14 +754,14 @@ drop function dfunc(anyelement);
-- check defaults for variadics
create function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- fail
select dfunc(10);
select dfunc(10,20);
create or replace function dfunc(a variadic int[] default array[]::int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- now ok
select dfunc(10);
@@ -769,7 +769,7 @@ select dfunc(10,20);
-- can't remove the default once it exists
create or replace function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
\df dfunc
@@ -779,15 +779,15 @@ drop function dfunc(a variadic int[]);
create function dfunc(int = 1, int = 2, int = 3) returns int as $$
select 3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(text) returns text as $$
select $1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- dfunc(narg=2) and dfunc(narg=3) are ambiguous
select dfunc(1); -- fail
@@ -806,7 +806,7 @@ drop function dfunc(text);
create function dfunc(a int, b int, c int = 0, d int = 0)
returns table (a int, b int, c int, d int) as $$
select $1, $2, $3, $4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc(10,20,30)).*;
select (dfunc(a := 10, b := 20, c := 30)).*;
@@ -829,7 +829,7 @@ drop function dfunc(int, int, int, int);
create function dfunc(a varchar, b numeric, c date = current_date)
returns table (a varchar, b numeric, c date) as $$
select $1, $2, $3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc('Hello World', 20, '2009-07-25'::date)).*;
select * from dfunc('Hello World', 20, '2009-07-25'::date);
@@ -844,7 +844,7 @@ drop function dfunc(varchar, numeric, date);
create function dfunc(a varchar = 'def a', out _a varchar, c numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc()).*;
select * from dfunc();
@@ -859,26 +859,26 @@ select * from dfunc(c := 100);
create or replace function dfunc(a varchar = 'def a', out _a varchar, x numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create or replace function dfunc(a varchar = 'def a', out _a varchar, numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
drop function dfunc(varchar, numeric);
--fail, named parameters are not unique
-create function testpolym(a int, a int) returns int as $$ select 1;$$ language sql;
-create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ language sql;
-create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ language sql;
-create function testpolym(a int, inout a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(a int, a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
+create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
+create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
+create function testpolym(a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
-- valid
-create function testpolym(a int, out a int) returns int as $$ select $1;$$ language sql;
+create function testpolym(a int, out a int) returns int as $$ select $1;$$ LANGUAGE SQLTEST;
select testpolym(37);
drop function testpolym(int);
-create function testpolym(a int) returns table(a int) as $$ select $1;$$ language sql;
+create function testpolym(a int) returns table(a int) as $$ select $1;$$ LANGUAGE SQLTEST;
select * from testpolym(37);
drop function testpolym(int);
@@ -886,7 +886,7 @@ drop function testpolym(int);
create function dfunc(a anyelement, b anyelement = null, flag bool = true)
returns anyelement as $$
select case when $3 then $1 else $2 end;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(1,2);
select dfunc('a'::text, 'b'); -- positional notation with default
@@ -957,7 +957,7 @@ drop function dfunc(anyelement, anyelement, bool);
create function anyctest(anycompatible, anycompatible)
returns anycompatible as $$
select greatest($1, $2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.3) x;
@@ -969,7 +969,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatible)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.3) x;
@@ -980,7 +980,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatiblearray)
returns anycompatiblearray as $$
select array[$1] || $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[12]) x;
select x, pg_typeof(x) from anyctest(11, array[12.3]) x;
@@ -994,7 +994,7 @@ drop function anyctest(anycompatible, anycompatiblearray);
create function anyctest(anycompatible, anycompatiblerange)
returns anycompatiblerange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, int4range(4,7)) x;
select x, pg_typeof(x) from anyctest(11, numrange(4,7)) x;
@@ -1007,7 +1007,7 @@ drop function anyctest(anycompatible, anycompatiblerange);
create function anyctest(anycompatiblerange, anycompatiblerange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(int4range(11,12), int4range(4,7)) x;
select x, pg_typeof(x) from anyctest(int4range(11,12), numrange(4,7)) x; -- fail
@@ -1018,12 +1018,12 @@ drop function anyctest(anycompatiblerange, anycompatiblerange);
create function anyctest(anycompatible)
returns anycompatiblerange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function anyctest(anycompatible, anycompatiblemultirange)
returns anycompatiblemultirange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, multirange(int4range(4,7))) x;
select x, pg_typeof(x) from anyctest(11, multirange(numrange(4,7))) x;
@@ -1036,7 +1036,7 @@ drop function anyctest(anycompatible, anycompatiblemultirange);
create function anyctest(anycompatiblemultirange, anycompatiblemultirange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(int4range(4,7))) x;
select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(numrange(4,7))) x; -- fail
@@ -1047,12 +1047,12 @@ drop function anyctest(anycompatiblemultirange, anycompatiblemultirange);
create function anyctest(anycompatible)
returns anycompatiblemultirange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function anyctest(anycompatiblenonarray, anycompatiblenonarray)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.3) x;
@@ -1064,7 +1064,7 @@ create function anyctest(a anyelement, b anyarray,
c anycompatible, d anycompatible)
returns anycompatiblearray as $$
select array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[1, 2], 42, 34.5) x;
select x, pg_typeof(x) from anyctest(11, array[1, 2], point(1,2), point(3,4)) x;
@@ -1077,7 +1077,7 @@ drop function anyctest(a anyelement, b anyarray,
create function anyctest(variadic anycompatiblearray)
returns anycompatiblearray as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.2) x;
diff --git a/src/test/regress/sql/portals.sql b/src/test/regress/sql/portals.sql
index 52560ac027..f540fee4d1 100644
--- a/src/test/regress/sql/portals.sql
+++ b/src/test/regress/sql/portals.sql
@@ -239,7 +239,7 @@ BEGIN;
CREATE FUNCTION declares_cursor(text)
RETURNS void
AS 'DECLARE c CURSOR FOR SELECT stringu1 FROM tenk1 WHERE stringu1 LIKE $1;'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT declares_cursor('AB%');
@@ -256,10 +256,10 @@ ROLLBACK;
create temp table tt1(f1 int);
create function count_tt1_v() returns int8 as
-'select count(*) from tt1' language sql volatile;
+'select count(*) from tt1' LANGUAGE SQLTEST volatile;
create function count_tt1_s() returns int8 as
-'select count(*) from tt1' language sql stable;
+'select count(*) from tt1' LANGUAGE SQLTEST stable;
begin;
@@ -512,7 +512,7 @@ DROP TABLE cursor;
-- per bug report in 8336843.9833.1399385291498.JavaMail.root@quick
begin;
create function nochange(int) returns int
- as 'select $1 limit 1' language sql stable;
+ as 'select $1 limit 1' LANGUAGE SQLTEST stable;
declare c cursor for select * from int8_tbl limit nochange(3);
fetch all from c;
move backward all in c;
diff --git a/src/test/regress/sql/privileges.sql b/src/test/regress/sql/privileges.sql
index 4911ad4add..7ca26f1104 100644
--- a/src/test/regress/sql/privileges.sql
+++ b/src/test/regress/sql/privileges.sql
@@ -481,16 +481,16 @@ END;
-- switch to superuser
\c -
-REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user1; -- ok
+REVOKE ALL PRIVILEGES ON LANGUAGE sqltest FROM PUBLIC;
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user1; -- ok
GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
SET SESSION AUTHORIZATION regress_priv_user1;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user2; -- fail
-CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql;
-CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user2; -- fail
+CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest;
+CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE priv_testagg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sql;
+CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sqltest;
REVOKE ALL ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) TO regress_priv_user2;
@@ -507,12 +507,12 @@ GRANT ALL PRIVILEGES ON PROCEDURE priv_testproc1(int) TO regress_priv_user4;
CREATE FUNCTION priv_testfunc4(boolean) RETURNS text
AS 'select col1 from atest2 where col2 = $1;'
- LANGUAGE sql SECURITY DEFINER;
+ LANGUAGE sqltest SECURITY DEFINER;
GRANT EXECUTE ON FUNCTION priv_testfunc4(boolean) TO regress_priv_user3;
SET SESSION AUTHORIZATION regress_priv_user2;
SELECT priv_testfunc1(5), priv_testfunc2(5); -- ok
-CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail
+CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest; -- fail
SELECT priv_testagg1(x) FROM (VALUES (1), (2), (3)) _(x); -- ok
CALL priv_testproc1(6); -- ok
@@ -536,7 +536,7 @@ DROP PROCEDURE priv_testproc1(int); -- fail
DROP FUNCTION priv_testfunc1(int); -- ok
-- restore to sanity
-GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
+GRANT ALL PRIVILEGES ON LANGUAGE sqltest TO PUBLIC;
-- verify privilege checks on array-element coercions
BEGIN;
@@ -572,13 +572,13 @@ CREATE AGGREGATE priv_testagg1a(priv_testdomain1) (sfunc = int4_sum, stype = big
CREATE DOMAIN priv_testdomain2a AS priv_testdomain1;
CREATE DOMAIN priv_testdomain3a AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3a) WITH FUNCTION castfunc(int);
DROP FUNCTION castfunc(int) CASCADE;
DROP DOMAIN priv_testdomain3a;
-CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
-CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
CREATE OPERATOR !+! (PROCEDURE = int4pl, LEFTARG = priv_testdomain1, RIGHTARG = priv_testdomain1);
@@ -609,11 +609,11 @@ CREATE AGGREGATE priv_testagg1b(priv_testdomain1) (sfunc = int4_sum, stype = big
CREATE DOMAIN priv_testdomain2b AS priv_testdomain1;
CREATE DOMAIN priv_testdomain3b AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3b) WITH FUNCTION castfunc(int);
-CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
-CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
CREATE OPERATOR !! (PROCEDURE = priv_testfunc5b, RIGHTARG = priv_testdomain1);
@@ -813,9 +813,9 @@ SELECT has_table_privilege('regress_priv_user1', 'atest4', 'SELECT WITH GRANT OP
CREATE ROLE regress_sro_user;
SET SESSION AUTHORIZATION regress_sro_user;
-CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sql AS
+CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sqltest AS
'GRANT regress_priv_group2 TO regress_sro_user';
-CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'DECLARE c CURSOR WITH HOLD FOR SELECT unwanted_grant(); SELECT true';
-- REFRESH of this MV will queue a GRANT at end of transaction
CREATE MATERIALIZED VIEW sro_mv AS SELECT mv_action() WITH NO DATA;
@@ -831,7 +831,7 @@ CREATE FUNCTION sro_trojan() RETURNS trigger LANGUAGE plpgsql AS
CREATE CONSTRAINT TRIGGER t AFTER INSERT ON sro_trojan_table
INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE sro_trojan();
-- Now, REFRESH will issue such an INSERT, queueing the GRANT
-CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'INSERT INTO sro_trojan_table DEFAULT VALUES; SELECT true';
REFRESH MATERIALIZED VIEW sro_mv;
\c -
@@ -845,7 +845,7 @@ DROP ROLE regress_sro_user;
-- Admin options
SET SESSION AUTHORIZATION regress_priv_user4;
-CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: had ADMIN OPTION
SET ROLE regress_priv_group2;
@@ -859,7 +859,7 @@ GRANT regress_priv_group2 TO regress_priv_user5; -- fails: SET ROLE did not help
SET SESSION AUTHORIZATION regress_priv_group2;
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: a role can self-admin
-CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
SELECT dogrant_fails(); -- fails: no self-admin in SECURITY DEFINER
DROP FUNCTION dogrant_fails();
@@ -1055,9 +1055,9 @@ SELECT has_schema_privilege('regress_priv_user2', 'testns5', 'CREATE'); -- no
SET ROLE regress_priv_user1;
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- no
SELECT has_function_privilege('regress_priv_user2', 'testns.agg1(int)', 'EXECUTE'); -- no
@@ -1066,11 +1066,11 @@ SELECT has_function_privilege('regress_priv_user2', 'testns.bar()', 'EXECUTE');
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT EXECUTE ON ROUTINES to public;
DROP FUNCTION testns.foo();
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
DROP AGGREGATE testns.agg1(int);
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
DROP PROCEDURE testns.bar();
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- yes
SELECT has_function_privilege('regress_priv_user2', 'testns.agg1(int)', 'EXECUTE'); -- yes
@@ -1131,9 +1131,9 @@ REVOKE ALL ON ALL TABLES IN SCHEMA testns FROM regress_priv_user1;
SELECT has_table_privilege('regress_priv_user1', 'testns.t1', 'SELECT'); -- false
SELECT has_table_privilege('regress_priv_user1', 'testns.t2', 'SELECT'); -- false
-CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE testns.priv_testagg(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sql;
+CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user1', 'testns.priv_testfunc(int)', 'EXECUTE'); -- true by default
SELECT has_function_privilege('regress_priv_user1', 'testns.priv_testagg(int)', 'EXECUTE'); -- true by default
@@ -1242,7 +1242,7 @@ DROP GROUP regress_priv_group1;
DROP GROUP regress_priv_group2;
-- these are needed to clean up permissions
-REVOKE USAGE ON LANGUAGE sql FROM regress_priv_user1;
+REVOKE USAGE ON LANGUAGE sqltest FROM regress_priv_user1;
DROP OWNED BY regress_priv_user1;
DROP USER regress_priv_user1;
diff --git a/src/test/regress/sql/rangefuncs.sql b/src/test/regress/sql/rangefuncs.sql
index 3c436028da..6ab1f10b01 100644
--- a/src/test/regress/sql/rangefuncs.sql
+++ b/src/test/regress/sql/rangefuncs.sql
@@ -3,7 +3,7 @@ INSERT INTO rngfunc2 VALUES(1, 11);
INSERT INTO rngfunc2 VALUES(2, 22);
INSERT INTO rngfunc2 VALUES(1, 111);
-CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQL;
+CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQLTEST;
-- function with ORDINALITY
select * from rngfunct(1) with ordinality as z(a,b,ord);
@@ -88,7 +88,7 @@ INSERT INTO rngfunc VALUES(1,2,'Ed');
INSERT INTO rngfunc VALUES(2,1,'Mary');
-- sql, proretset = f, prorettype = b
-CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc1(1) AS t1;
SELECT * FROM getrngfunc1(1) WITH ORDINALITY AS t1(v,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc1(1);
@@ -99,7 +99,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc2(1) AS t1;
SELECT * FROM getrngfunc2(1) WITH ORDINALITY AS t1(v,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc2(1);
@@ -110,7 +110,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc3(1) AS t1;
SELECT * FROM getrngfunc3(1) WITH ORDINALITY AS t1(v,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc3(1);
@@ -121,7 +121,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = c
-CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc4(1) AS t1;
SELECT * FROM getrngfunc4(1) WITH ORDINALITY AS t1(a,b,c,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc4(1);
@@ -132,7 +132,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = c
-CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc5(1) AS t1;
SELECT * FROM getrngfunc5(1) WITH ORDINALITY AS t1(a,b,c,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc5(1);
@@ -143,7 +143,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = record
-CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc6(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
SELECT * FROM ROWS FROM( getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY;
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc6(1) AS
@@ -157,7 +157,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = record
-CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc7(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
SELECT * FROM ROWS FROM( getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY;
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc7(1) AS
@@ -232,7 +232,7 @@ CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq1;
CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq2;
CREATE TYPE rngfunc_rescan_t AS (i integer, s bigint);
-CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQL;
+CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQLTEST;
-- plpgsql functions use materialize mode
CREATE FUNCTION rngfunc_mat(int,int) RETURNS setof rngfunc_rescan_t AS 'begin for i in $1..$2 loop return next (i, nextval(''rngfunc_rescan_seq2'')); end loop; end;' LANGUAGE plpgsql;
@@ -344,32 +344,32 @@ DROP SEQUENCE rngfunc_rescan_seq2;
--
CREATE FUNCTION rngfunc(in f1 int, out f2 int)
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
SELECT rngfunc(42);
SELECT * FROM rngfunc(42);
SELECT * FROM rngfunc(42) AS p(x);
-- explicit spec of return type is OK
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
-- error, wrong result type
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS float
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
-- with multiple OUT params you must get a RECORD result
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text)
RETURNS record
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
CREATE OR REPLACE FUNCTION rngfuncr(in f1 int, out f2 int, out text)
-AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncr(f1) FROM int4_tbl;
SELECT * FROM rngfuncr(42);
SELECT * FROM rngfuncr(42) AS p(a,b);
CREATE OR REPLACE FUNCTION rngfuncb(in f1 int, inout f2 int, out text)
-AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncb(f1, f1/2) FROM int4_tbl;
SELECT * FROM rngfuncb(42, 99);
SELECT * FROM rngfuncb(42, 99) AS p(a,b);
@@ -384,7 +384,7 @@ DROP FUNCTION rngfuncb(in f1 int, inout f2 int);
--
CREATE FUNCTION dup (f1 anyelement, f2 out anyelement, f3 out anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
SELECT dup('xyz'); -- fails
SELECT dup('xyz'::text);
@@ -392,23 +392,23 @@ SELECT * FROM dup('xyz'::text);
-- fails, as we are attempting to rename first argument
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
DROP FUNCTION dup(anyelement);
-- equivalent behavior, though different name exposed for input arg
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
DROP FUNCTION dup(anyelement);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 int, out f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
CREATE FUNCTION dup (f1 anycompatible, f2 anycompatiblearray, f3 out anycompatible, f4 out anycompatiblearray)
-AS 'select $1, $2' LANGUAGE sql;
+AS 'select $1, $2' LANGUAGE sqltest;
SELECT dup(22, array[44]);
SELECT dup(4.5, array[44]);
SELECT dup(22, array[44::bigint]);
@@ -417,7 +417,7 @@ SELECT *, pg_typeof(f3), pg_typeof(f4) FROM dup(22, array[44::bigint]);
DROP FUNCTION dup(f1 anycompatible, f2 anycompatiblearray);
CREATE FUNCTION dup (f1 anycompatiblerange, f2 out anycompatible, f3 out anycompatiblearray, f4 out anycompatiblerange)
-AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sql;
+AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sqltest;
SELECT dup(int4range(4,7));
SELECT dup(numrange(4,7));
SELECT dup(textrange('aaa', 'bbb'));
@@ -426,7 +426,7 @@ DROP FUNCTION dup(f1 anycompatiblerange);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 anyarray, out f2 anycompatible, out f3 anycompatiblearray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
--
-- table functions
@@ -434,7 +434,7 @@ AS 'select $1, array[$1,$1]' LANGUAGE sql;
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a int)
-AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sql;
+AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc();
DROP FUNCTION rngfunc();
@@ -442,14 +442,14 @@ CREATE OR REPLACE FUNCTION rngfunc(int)
RETURNS TABLE(a int, b int)
AS $$ SELECT a, b
FROM generate_series(1,$1) a(a),
- generate_series(1,$1) b(b) $$ LANGUAGE sql;
+ generate_series(1,$1) b(b) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc(3);
DROP FUNCTION rngfunc(int);
-- case that causes change of typmod knowledge during inlining
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a varchar(5))
-AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sql STABLE;
+AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sqltest STABLE;
SELECT * FROM rngfunc() GROUP BY 1;
DROP FUNCTION rngfunc();
@@ -461,7 +461,7 @@ create temp table tt(f1 serial, data text);
create function insert_tt(text) returns int as
$$ insert into tt(data) values($1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('foo');
select insert_tt('bar');
@@ -470,7 +470,7 @@ select * from tt;
-- insert will execute to completion even if function needs just 1 row
create or replace function insert_tt(text) returns int as
$$ insert into tt(data) values($1),($1||$1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('fool');
select * from tt;
@@ -478,7 +478,7 @@ select * from tt;
-- setof does what's expected
create or replace function insert_tt2(text,text) returns setof int as
$$ insert into tt(data) values($1),($2) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt2('foolish','barrish');
select * from insert_tt2('baz','quux');
@@ -515,7 +515,7 @@ select * from tt_log;
-- test case for a whole-row-variable bug
create function rngfunc1(n integer, out a text, out b text)
returns setof record
- language sql
+ LANGUAGE SQLTEST
as $$ select 'foo ' || i, 'bar ' || i from generate_series(1,$1) i $$;
set work_mem='64kB';
@@ -531,7 +531,7 @@ drop function rngfunc1(n integer);
create function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql strict immutable;
+$$ LANGUAGE SQLTEST strict immutable;
select array_to_set(array['one', 'two']);
select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text);
@@ -549,7 +549,7 @@ explain (verbose, costs off)
create or replace function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select array_to_set(array['one', 'two']);
select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text);
@@ -562,7 +562,7 @@ create temp table rngfunc(f1 int8, f2 int8);
create function testrngfunc() returns record as $$
insert into rngfunc values (1,2) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
select * from testrngfunc() as t(f1 int8,f2 int8);
@@ -572,7 +572,7 @@ drop function testrngfunc();
create function testrngfunc() returns setof record as $$
insert into rngfunc values (1,2), (3,4) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
select * from testrngfunc() as t(f1 int8,f2 int8);
@@ -585,7 +585,7 @@ create type rngfunc_type as (f1 numeric(35,6), f2 numeric(35,2));
create function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
@@ -596,7 +596,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
@@ -609,7 +609,7 @@ drop function testrngfunc();
create function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
@@ -620,7 +620,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
@@ -631,7 +631,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 1, 2 union select 3, 4 order by 1;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
@@ -658,14 +658,14 @@ alter table users drop column todrop;
create or replace function get_first_user() returns users as
$$ SELECT * FROM users ORDER BY userid LIMIT 1; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_first_user();
SELECT * FROM get_first_user();
create or replace function get_users() returns setof users as
$$ SELECT * FROM users ORDER BY userid; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_users();
SELECT * FROM get_users();
@@ -698,7 +698,7 @@ drop table users;
create or replace function rngfuncbar() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar ; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select rngfuncbar();
select * from rngfuncbar();
@@ -710,17 +710,17 @@ drop function rngfuncbar();
-- check handling of a SQL function with multiple OUT params (bug #5777)
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1) $$ language sql;
+$$ select (1, 2.1) $$ LANGUAGE SQLTEST;
select * from rngfuncbar();
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2) $$ language sql;
+$$ select (1, 2) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1, 3) $$ language sql;
+$$ select (1, 2.1, 3) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
@@ -730,7 +730,7 @@ drop function rngfuncbar();
create function extractq2(t int8_tbl) returns int8 as $$
select t.q2
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2(int8_tbl) f(x);
@@ -739,7 +739,7 @@ select x from int8_tbl, extractq2(int8_tbl) f(x);
create function extractq2_2(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t) offset 0
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2(int8_tbl) f(x);
@@ -750,7 +750,7 @@ select x from int8_tbl, extractq2_2(int8_tbl) f(x);
create function extractq2_2_opt(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t)
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x);
diff --git a/src/test/regress/sql/rangetypes.sql b/src/test/regress/sql/rangetypes.sql
index e1b8917c0c..a65130f78b 100644
--- a/src/test/regress/sql/rangetypes.sql
+++ b/src/test/regress/sql/rangetypes.sql
@@ -465,7 +465,7 @@ drop type textrange2;
--
create function anyarray_anyrange_func(a anyarray, r anyrange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anyrange_func(ARRAY[1,2], int4range(10,20));
@@ -476,27 +476,27 @@ drop function anyarray_anyrange_func(anyarray, anyrange);
-- should fail
create function bogus_func(anyelement)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
-- should fail
create function bogus_func(int)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
create function range_add_bounds(anyrange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4range(1, 17));
select range_add_bounds(numrange(1.0001, 123.123));
create function rangetypes_sql(q anyrange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select rangetypes_sql(int4range(1,10), ARRAY[2,20]);
select rangetypes_sql(numrange(1,10), ARRAY[2,20]); -- match failure
create function anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatiblerange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], int4range(10,20));
@@ -509,7 +509,7 @@ drop function anycompatiblearray_anycompatiblerange_func(anycompatiblearray, any
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
--
-- Arrays of ranges
@@ -569,43 +569,43 @@ reset enable_sort;
-- infer anyrange from anyrange
create function outparam_succeed(i anyrange, out r anyrange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed(int4range(1,2));
create function outparam2_succeed(r anyrange, out lu anyarray, out ul anyarray)
as $$ select array[lower($1), upper($1)], array[upper($1), lower($1)] $$
- language sql;
+ LANGUAGE SQLTEST;
select * from outparam2_succeed(int4range(1,11));
-- infer anyarray from anyrange
create function outparam_succeed2(i anyrange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed2(int4range(int4range(1,2)));
-- infer anyelement from anyrange
create function inoutparam_succeed(out i anyelement, inout r anyrange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from inoutparam_succeed(int4range(1,2));
create function table_succeed(r anyrange)
returns table(l anyelement, u anyelement)
as $$ select lower($1), upper($1) $$
- language sql;
+ LANGUAGE SQLTEST;
select * from table_succeed(int4range(1,11));
-- should fail
create function outparam_fail(i anyelement, out r anyrange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
--should fail
create function inoutparam_fail(inout i anyelement, out r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
--should fail
create function table_fail(i anyelement) returns table(i anyelement, r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
diff --git a/src/test/regress/sql/rowtypes.sql b/src/test/regress/sql/rowtypes.sql
index 845e3305f3..d5613d287c 100644
--- a/src/test/regress/sql/rowtypes.sql
+++ b/src/test/regress/sql/rowtypes.sql
@@ -331,11 +331,11 @@ CREATE TYPE price_key AS (
CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
insert into price values (1,false,42), (10,false,100), (11,true,17.99);
@@ -357,19 +357,19 @@ create temp table compos (f1 int, f2 text);
create function fcompos1(v compos) returns void as $$
insert into compos values (v); -- fail
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos1(v compos) returns void as $$
insert into compos values (v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos2(v compos) returns void as $$
select fcompos1(v);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos3(v compos) returns void as $$
select fcompos1(fcompos3.v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select fcompos1(row(1,'one'));
select fcompos2(row(2,'two'));
@@ -399,7 +399,7 @@ insert into fullname values ('Joe', 'Blow');
select f.last from fullname f;
select last(f) from fullname f;
-create function longname(fullname) returns text language sql
+create function longname(fullname) returns text LANGUAGE SQLTEST
as $$select $1.first || ' ' || $1.last$$;
select f.longname from fullname f;
diff --git a/src/test/regress/sql/rules.sql b/src/test/regress/sql/rules.sql
index 744cf7ab54..832bf45356 100644
--- a/src/test/regress/sql/rules.sql
+++ b/src/test/regress/sql/rules.sql
@@ -431,7 +431,7 @@ create view rtest_vview4 as select X.a, X.b, count(Y.a) as refcount
group by X.a, X.b;
create function rtest_viewfunc1(int4) returns int4 as
'select count(*)::int4 from rtest_view2 where a = $1'
- language sql;
+ LANGUAGE SQLTEST;
create view rtest_vview5 as select a, b, rtest_viewfunc1(a) as refcount
from rtest_view1;
@@ -1174,7 +1174,7 @@ drop table hat_data;
-- Note that the function is kept around to stress pg_dump.
CREATE FUNCTION func_with_set_params() RETURNS integer
AS 'select 1;'
- LANGUAGE SQL
+ LANGUAGE SQLTEST
SET search_path TO PG_CATALOG
SET extra_float_digits TO 2
SET work_mem TO '4MB'
diff --git a/src/test/regress/sql/select.sql b/src/test/regress/sql/select.sql
index b5929b2eca..30cbc2e0e7 100644
--- a/src/test/regress/sql/select.sql
+++ b/src/test/regress/sql/select.sql
@@ -243,7 +243,7 @@ SELECT 1 AS x ORDER BY x;
-- But ORDER BY on a set-valued expression does
create function sillysrf(int) returns setof int as
- 'values (1),(10),(2),($1)' language sql immutable;
+ 'values (1),(10),(2),($1)' LANGUAGE SQLTEST immutable;
select sillysrf(42);
select sillysrf(-1) order by 1;
diff --git a/src/test/regress/sql/select_into.sql b/src/test/regress/sql/select_into.sql
index 7e903c339a..5dbf9cbe9f 100644
--- a/src/test/regress/sql/select_into.sql
+++ b/src/test/regress/sql/select_into.sql
@@ -90,7 +90,7 @@ DROP TABLE ctas_nodata_4;
CREATE FUNCTION make_table() RETURNS VOID
AS $$
CREATE TABLE created_table AS SELECT * FROM int8_tbl;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
SELECT make_table();
diff --git a/src/test/regress/sql/select_parallel.sql b/src/test/regress/sql/select_parallel.sql
index 5a01a98b26..705a4d9478 100644
--- a/src/test/regress/sql/select_parallel.sql
+++ b/src/test/regress/sql/select_parallel.sql
@@ -52,7 +52,7 @@ reset enable_parallel_append;
-- Parallel Append that runs serially
create function sp_test_func() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select sp_test_func() order by 1;
-- Parallel Append is not to be used when the subpath depends on the outer param
diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql
index 14fa0b247e..4929dbb3bd 100644
--- a/src/test/regress/sql/subscription.sql
+++ b/src/test/regress/sql/subscription.sql
@@ -28,7 +28,7 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB
CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false);
COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription';
-SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
+SELECT obj_description(s.oid, 'pg_sub') FROM pg_sub s;
-- fail - name already exists
CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false);
diff --git a/src/test/regress/sql/subselect.sql b/src/test/regress/sql/subselect.sql
index bd17f5d264..1f00fc0f5a 100644
--- a/src/test/regress/sql/subselect.sql
+++ b/src/test/regress/sql/subselect.sql
@@ -481,7 +481,7 @@ begin;
-- make an operator to allow it to succeed
create function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2';
create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text);
@@ -492,7 +492,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function results in unusual number of hash clauses,
-- which we can still cope with
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2 and $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2 and $1::text = $2';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
@@ -501,7 +501,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function causes LHS and RHS to be switched,
-- which we can't cope with, so hashing should be abandoned
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $2 = $1::text';
+LANGUAGE SQLTEST as 'select $2 = $1::text';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
diff --git a/src/test/regress/sql/temp.sql b/src/test/regress/sql/temp.sql
index 424d12b283..abd25c2b85 100644
--- a/src/test/regress/sql/temp.sql
+++ b/src/test/regress/sql/temp.sql
@@ -131,10 +131,10 @@ create temp table whereami (f1 text);
insert into whereami values ('temp');
create function public.whoami() returns text
- as $$select 'public'::text$$ language sql;
+ as $$select 'public'::text$$ LANGUAGE SQLTEST;
create function pg_temp.whoami() returns text
- as $$select 'temp'::text$$ language sql;
+ as $$select 'temp'::text$$ LANGUAGE SQLTEST;
-- default should have pg_temp implicitly first, but only for tables
select * from whereami;
@@ -248,11 +248,11 @@ drop table temp_inh_oncommit_test;
-- Function creation
begin;
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
prepare transaction 'twophase_func';
-- Function drop
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
begin;
drop function pg_temp.twophase_func();
prepare transaction 'twophase_func';
diff --git a/src/test/regress/sql/transactions.sql b/src/test/regress/sql/transactions.sql
index bf1016489d..a7a19adcf0 100644
--- a/src/test/regress/sql/transactions.sql
+++ b/src/test/regress/sql/transactions.sql
@@ -281,7 +281,7 @@ COMMIT;
--
select * from xacttest;
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' stable;
begin;
@@ -290,7 +290,7 @@ select * from xacttest;
rollback;
-- But a volatile function can see the partial results of the calling query
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' volatile;
begin;
diff --git a/src/test/regress/sql/typed_table.sql b/src/test/regress/sql/typed_table.sql
index 9ef0cdfcc7..057b5bd1b6 100644
--- a/src/test/regress/sql/typed_table.sql
+++ b/src/test/regress/sql/typed_table.sql
@@ -7,7 +7,7 @@ SELECT * FROM persons;
\d persons
CREATE FUNCTION get_all_persons() RETURNS SETOF person_type
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT * FROM persons;
$$;
@@ -57,7 +57,7 @@ CREATE TYPE person_type AS (id int, name text);
CREATE TABLE persons OF person_type;
INSERT INTO persons VALUES (1, 'test');
-CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$;
+CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQLTEST AS $$ SELECT length($1.name) $$;
SELECT id, namelen(persons) FROM persons;
CREATE TABLE persons2 OF person_type (
diff --git a/src/test/regress/sql/updatable_views.sql b/src/test/regress/sql/updatable_views.sql
index 09328e582b..47073f1925 100644
--- a/src/test/regress/sql/updatable_views.sql
+++ b/src/test/regress/sql/updatable_views.sql
@@ -394,7 +394,7 @@ INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i);
CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl;
CREATE FUNCTION rw_view1_aa(x rw_view1)
- RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql;
+ RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sqltest;
UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2
RETURNING rw_view1_aa(v), v.bb;
diff --git a/src/test/regress/sql/vacuum.sql b/src/test/regress/sql/vacuum.sql
index c7b5f96f6b..641d4bf16c 100644
--- a/src/test/regress/sql/vacuum.sql
+++ b/src/test/regress/sql/vacuum.sql
@@ -46,9 +46,9 @@ CREATE TABLE vaccluster (i INT PRIMARY KEY);
ALTER TABLE vaccluster CLUSTER ON vaccluster_pkey;
CLUSTER vaccluster;
-CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL
+CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQLTEST
AS 'ANALYZE pg_am';
-CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL
+CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQLTEST
AS 'SELECT $1 FROM do_analyze()';
CREATE INDEX ON vaccluster(wrap_do_analyze(i));
INSERT INTO vaccluster VALUES (1), (2);
diff --git a/src/test/regress/sql/window.sql b/src/test/regress/sql/window.sql
index eae5fa6017..cfcd942488 100644
--- a/src/test/regress/sql/window.sql
+++ b/src/test/regress/sql/window.sql
@@ -982,15 +982,15 @@ SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four
CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE AGGREGATE logging_agg_nonstrict (anyelement)
(
@@ -1014,15 +1014,15 @@ CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement)
CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '*' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '+' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE AGGREGATE logging_agg_strict (text)
(
@@ -1134,7 +1134,7 @@ ORDER BY i;
CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS
$$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$
-LANGUAGE SQL STRICT;
+LANGUAGE SQLTEST STRICT;
CREATE AGGREGATE sum_int_randomrestart (int4)
(
@@ -1324,7 +1324,7 @@ AS $$
SELECT array_agg(s) OVER w
FROM generate_series(1,5) s
WINDOW w AS (ORDER BY s ROWS BETWEEN CURRENT ROW AND GROUP_SIZE FOLLOWING)
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQLTEST STABLE;
EXPLAIN (costs off) SELECT * FROM pg_temp.f(2);
SELECT * FROM pg_temp.f(2);
diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl
index 0680f44a1a..3703478be1 100644
--- a/src/test/subscription/t/001_rep_changes.pl
+++ b/src/test/subscription/t/001_rep_changes.pl
@@ -19,7 +19,7 @@ $node_subscriber->start;
$node_publisher->safe_psql(
'postgres',
"CREATE FUNCTION public.pg_get_replica_identity_index(int)
- RETURNS regclass LANGUAGE sql AS 'SELECT 1/0'"); # shall not call
+ RETURNS regclass LANGUAGE sqltest AS 'SELECT 1/0'"); # shall not call
$node_publisher->safe_psql('postgres',
"CREATE TABLE tab_notrep AS SELECT generate_series(1,10) AS a");
$node_publisher->safe_psql('postgres',
@@ -89,7 +89,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Also wait for initial table sync to finish
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
@@ -336,7 +336,7 @@ $node_publisher->poll_query_until('postgres',
$node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub_renamed");
$result = $node_subscriber->safe_psql('postgres',
- "SELECT count(*) FROM pg_subscription");
+ "SELECT count(*) FROM pg_sub");
is($result, qq(0), 'check subscription was dropped on subscriber');
$result = $node_publisher->safe_psql('postgres',
@@ -344,7 +344,7 @@ $result = $node_publisher->safe_psql('postgres',
is($result, qq(0), 'check replication slot was dropped on publisher');
$result = $node_subscriber->safe_psql('postgres',
- "SELECT count(*) FROM pg_subscription_rel");
+ "SELECT count(*) FROM pg_sub_rel");
is($result, qq(0),
'check subscription relation status was dropped on subscriber');
diff --git a/src/test/subscription/t/002_types.pl b/src/test/subscription/t/002_types.pl
index aedcab2fbc..c25cc34a2c 100644
--- a/src/test/subscription/t/002_types.pl
+++ b/src/test/subscription/t/002_types.pl
@@ -93,7 +93,7 @@ my $ddl = qq(
);
SET check_function_bodies=off;
- CREATE FUNCTION public.monot_incr(int) RETURNS bool LANGUAGE sql
+ CREATE FUNCTION public.monot_incr(int) RETURNS bool LANGUAGE sqltest
AS ' select \$1 > max(a) from public.tst_dom_constr; ';
CREATE DOMAIN monot_int AS int CHECK (monot_incr(VALUE));
CREATE TABLE public.tst_dom_constr (a monot_int););
@@ -115,7 +115,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Wait for initial sync to finish as well
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/004_sync.pl b/src/test/subscription/t/004_sync.pl
index e111ab9181..1d735073fc 100644
--- a/src/test/subscription/t/004_sync.pl
+++ b/src/test/subscription/t/004_sync.pl
@@ -40,7 +40,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Also wait for initial table sync to finish
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
@@ -60,7 +60,7 @@ $node_subscriber->safe_psql('postgres',
);
# but it will be stuck on data copy as it will fail on constraint
-my $started_query = "SELECT srsubstate = 'd' FROM pg_subscription_rel;";
+my $started_query = "SELECT srsubstate = 'd' FROM pg_sub_rel;";
$node_subscriber->poll_query_until('postgres', $started_query)
or die "Timed out while waiting for subscriber to start sync";
@@ -83,7 +83,7 @@ $node_subscriber->safe_psql('postgres',
# wait for it to start
$node_subscriber->poll_query_until('postgres',
- "SELECT pid IS NOT NULL FROM pg_stat_subscription WHERE subname = 'tap_sub2' AND relid IS NULL"
+ "SELECT pid IS NOT NULL FROM pg_stat_sub WHERE subname = 'tap_sub2' AND relid IS NULL"
) or die "Timed out while waiting for subscriber to start";
# and drop both subscriptions
@@ -92,7 +92,7 @@ $node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub2");
# check subscriptions are removed
$result = $node_subscriber->safe_psql('postgres',
- "SELECT count(*) FROM pg_subscription");
+ "SELECT count(*) FROM pg_sub");
is($result, qq(0), 'second and third sub are dropped');
# remove the conflicting data
diff --git a/src/test/subscription/t/005_encoding.pl b/src/test/subscription/t/005_encoding.pl
index aec7a17a78..f62ac885a7 100644
--- a/src/test/subscription/t/005_encoding.pl
+++ b/src/test/subscription/t/005_encoding.pl
@@ -33,7 +33,7 @@ $node_publisher->wait_for_catchup('mysub');
# Wait for initial sync to finish as well
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/006_rewrite.pl b/src/test/subscription/t/006_rewrite.pl
index c6cda10a19..c1d8058f70 100644
--- a/src/test/subscription/t/006_rewrite.pl
+++ b/src/test/subscription/t/006_rewrite.pl
@@ -29,7 +29,7 @@ $node_publisher->wait_for_catchup('mysub');
# Wait for initial sync to finish as well
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/008_diff_schema.pl b/src/test/subscription/t/008_diff_schema.pl
index 963334ed89..cdcff2d695 100644
--- a/src/test/subscription/t/008_diff_schema.pl
+++ b/src/test/subscription/t/008_diff_schema.pl
@@ -39,7 +39,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Also wait for initial table sync to finish
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/010_truncate.pl b/src/test/subscription/t/010_truncate.pl
index be2c0bdc35..ac46e28400 100644
--- a/src/test/subscription/t/010_truncate.pl
+++ b/src/test/subscription/t/010_truncate.pl
@@ -63,7 +63,7 @@ $node_subscriber->safe_psql('postgres',
# Wait for initial sync of all subscriptions
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/011_generated.pl b/src/test/subscription/t/011_generated.pl
index f35d1cba4c..08bc828625 100644
--- a/src/test/subscription/t/011_generated.pl
+++ b/src/test/subscription/t/011_generated.pl
@@ -38,7 +38,7 @@ $node_subscriber->safe_psql('postgres',
# Wait for initial sync of all subscriptions
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/013_partition.pl b/src/test/subscription/t/013_partition.pl
index a04c03a7e2..27c7300ebd 100644
--- a/src/test/subscription/t/013_partition.pl
+++ b/src/test/subscription/t/013_partition.pl
@@ -89,7 +89,7 @@ $node_subscriber2->safe_psql('postgres',
# Wait for initial sync of all subscriptions
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber1->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
$node_subscriber2->poll_query_until('postgres', $synced_query)
diff --git a/src/test/subscription/t/014_binary.pl b/src/test/subscription/t/014_binary.pl
index 36a2f58e17..d1cc362e3a 100644
--- a/src/test/subscription/t/014_binary.pl
+++ b/src/test/subscription/t/014_binary.pl
@@ -45,7 +45,7 @@ $node_subscriber->safe_psql('postgres',
# Ensure nodes are in sync with each other
$node_publisher->wait_for_catchup('tsub');
$node_subscriber->poll_query_until('postgres',
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');"
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');"
) or die "Timed out while waiting for subscriber to synchronize data";
# Insert some content and make sure it's replicated across
diff --git a/src/test/subscription/t/015_stream.pl b/src/test/subscription/t/015_stream.pl
index 1b0e6fb9fb..9060e2e8f5 100644
--- a/src/test/subscription/t/015_stream.pl
+++ b/src/test/subscription/t/015_stream.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/016_stream_subxact.pl b/src/test/subscription/t/016_stream_subxact.pl
index b6a2d10e91..e9fa91ec2e 100644
--- a/src/test/subscription/t/016_stream_subxact.pl
+++ b/src/test/subscription/t/016_stream_subxact.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/017_stream_ddl.pl b/src/test/subscription/t/017_stream_ddl.pl
index be7d7d74e3..e8da520aa7 100644
--- a/src/test/subscription/t/017_stream_ddl.pl
+++ b/src/test/subscription/t/017_stream_ddl.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/018_stream_subxact_abort.pl b/src/test/subscription/t/018_stream_subxact_abort.pl
index ddf0621558..9a336ec1c8 100644
--- a/src/test/subscription/t/018_stream_subxact_abort.pl
+++ b/src/test/subscription/t/018_stream_subxact_abort.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
index 33e42edfef..a1c1c05785 100644
--- a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
+++ b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
@@ -39,7 +39,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/100_bugs.pl b/src/test/subscription/t/100_bugs.pl
index d1e407aacb..90f8f22cb5 100644
--- a/src/test/subscription/t/100_bugs.pl
+++ b/src/test/subscription/t/100_bugs.pl
@@ -30,7 +30,7 @@ $node_publisher->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int)");
$node_publisher->safe_psql('postgres',
- "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'"
+ "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQLTEST AS 'select x * 2'"
);
# an index with a predicate that lends itself to constant expressions
@@ -43,7 +43,7 @@ $node_subscriber->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int)");
$node_subscriber->safe_psql('postgres',
- "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'"
+ "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQLTEST AS 'select x * 2'"
);
$node_subscriber->safe_psql('postgres',
@@ -145,7 +145,7 @@ $node_twoways->safe_psql(
# XXX maybe this should be integrated in wait_for_catchup() itself.
$node_twoways->wait_for_catchup('testsub');
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_twoways->poll_query_until('d2', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 266098e193..3edf16e25e 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -278,9 +278,9 @@ sub mangle_plpython3
foreach my $test (@$tests)
{
local $/ = undef;
- foreach my $dir ('sql', 'expected')
+ foreach my $dir ('sqltest', 'expected')
{
- my $extension = ($dir eq 'sql' ? 'sql' : 'out');
+ my $extension = ($dir eq 'sqltest' ? 'sqltest' : 'out');
my @files =
glob("$dir/$test.$extension $dir/${test}_[0-9].$extension");
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 943142ced8..332c2620ae 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -747,8 +747,8 @@ FormData_pg_sequence_data
FormData_pg_shdepend
FormData_pg_statistic
FormData_pg_statistic_ext
-FormData_pg_subscription
-FormData_pg_subscription_rel
+FormData_pg_sub
+FormData_pg_sub_rel
FormData_pg_tablespace
FormData_pg_transform
FormData_pg_trigger
@@ -803,8 +803,8 @@ Form_pg_sequence_data
Form_pg_shdepend
Form_pg_statistic
Form_pg_statistic_ext
-Form_pg_subscription
-Form_pg_subscription_rel
+Form_pg_sub
+Form_pg_sub_rel
Form_pg_tablespace
Form_pg_transform
Form_pg_trigger
diff --git a/src/tutorial/funcs.source b/src/tutorial/funcs.source
index 542b5c81ec..2f2c38fac2 100644
--- a/src/tutorial/funcs.source
+++ b/src/tutorial/funcs.source
@@ -22,7 +22,7 @@
-- returns 1
CREATE FUNCTION one() RETURNS integer
- AS 'SELECT 1 as ONE' LANGUAGE SQL;
+ AS 'SELECT 1 as ONE' LANGUAGE SQLTEST;
--
-- functions can be used in any expressions (eg. in the target list or
@@ -35,7 +35,7 @@ SELECT one() AS answer;
-- function returns the sum of its two arguments:
CREATE FUNCTION add_em(integer, integer) RETURNS integer
- AS 'SELECT $1 + $2' LANGUAGE SQL;
+ AS 'SELECT $1 + $2' LANGUAGE SQLTEST;
SELECT add_em(1, 2) AS answer;
@@ -65,7 +65,7 @@ INSERT INTO EMP VALUES ('Ginger', 4800, 30, '(2,4)');
-- double_salary takes a tuple of the EMP table
CREATE FUNCTION double_salary(EMP) RETURNS integer
- AS 'SELECT $1.salary * 2 AS salary' LANGUAGE SQL;
+ AS 'SELECT $1.salary * 2 AS salary' LANGUAGE SQLTEST;
SELECT name, double_salary(EMP) AS dream
FROM EMP
@@ -80,7 +80,7 @@ CREATE FUNCTION new_emp() RETURNS EMP
1000 AS salary,
25 AS age,
''(2,2)''::point AS cubicle'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
-- you can then project a column out of resulting the tuple by using the
-- "function notation" for projection columns. (ie. bar(foo) is equivalent
@@ -91,7 +91,7 @@ SELECT name(new_emp()) AS nobody;
-- let's try one more function that returns tuples
CREATE FUNCTION high_pay() RETURNS setof EMP
AS 'SELECT * FROM EMP where salary > 1500'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT name(high_pay()) AS overpaid;
@@ -109,7 +109,7 @@ SELECT * FROM EMP;
CREATE FUNCTION clean_EMP () RETURNS integer
AS 'DELETE FROM EMP WHERE EMP.salary <= 0;
SELECT 1 AS ignore_this'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT clean_EMP();
On Wed, Jan 27, 2021 at 07:32:42PM +0300, Anastasia Lubennikova wrote:
On 27.01.2021 14:21, Noah Misch wrote:
On Mon, Jan 25, 2021 at 10:14:43PM +0300, Anastasia Lubennikova wrote:
1) Could you please clarify, what do you mean by REVOKE failures?
I tried following example:
Start 9.6 cluster.
REVOKE ALL ON function pg_switch_xlog() FROM public;
REVOKE ALL ON function pg_switch_xlog() FROM backup;The upgrade to the current master passes with and without patch.
It seems that current implementation of pg_upgrade doesn't take into account
revoke ACLs.I think you can observe it by adding "revoke all on function
pg_stat_get_subscription from public;" to test_add_acl_to_catalog_objects.sql
and then rerunning your test script. pg_dump will reproduce that REVOKE,
which would fail if postgresql.org had removed that function. That's fine, so
long as a comment mentions the limitation.In the updated patch, I implemented generation of both GRANT ALL and REVOKE
ALL for problematic objects. If I understand it correctly, these calls will
clean object's ACL completely. And I see no harm in doing this, because the
objects don't exist in the new cluster anyway.To test it I attempted to reproduce the problem, using attached
test_revoke.sql in the test. Still, pg_upgrade works fine without any
adjustments. I'd be grateful if you test it some more.
test_revoke.sql has "revoke all on function pg_stat_get_subscription() from
test", which does nothing. You need something that causes a REVOKE in pg_dump
output. Worked example:
=== shell script
set -x
createuser test
pg_dump | grep -E 'GRANT|REVOKE'
psql -Xc 'revoke all on function pg_stat_get_subscription() from test;'
psql -Xc 'revoke all on function pg_stat_get_subscription from test;'
pg_dump | grep -E 'GRANT|REVOKE'
psql -Xc 'revoke all on function pg_stat_get_subscription from public;'
pg_dump | grep -E 'GRANT|REVOKE'
=== output
+ createuser test
+ pg_dump
+ grep -E 'GRANT|REVOKE'
+ psql -Xc 'revoke all on function pg_stat_get_subscription() from test;'
ERROR: function pg_stat_get_subscription() does not exist
+ psql -Xc 'revoke all on function pg_stat_get_subscription from test;'
REVOKE
+ pg_dump
+ grep -E 'GRANT|REVOKE'
+ psql -Xc 'revoke all on function pg_stat_get_subscription from public;'
REVOKE
+ pg_dump
+ grep -E 'GRANT|REVOKE'
REVOKE ALL ON FUNCTION pg_catalog.pg_stat_get_subscription(subid oid, OUT subid oid, OUT relid oid, OUT pid integer, OUT received_lsn pg_lsn, OUT last_msg_send_time timestamp with time zone, OUT last_msg_receipt_time timestamp with time zone, OUT latest_end_lsn pg_lsn, OUT latest_end_time timestamp with time zone) FROM PUBLIC;
That REVOKE is going to fail if the upgrade target cluster lacks the function
in question, and your test_rename_catalog_objects_v13 does simulate
pg_stat_get_subscription not existing.
On 28.01.2021 09:55, Noah Misch wrote:
On Wed, Jan 27, 2021 at 07:32:42PM +0300, Anastasia Lubennikova wrote:
On 27.01.2021 14:21, Noah Misch wrote:
On Mon, Jan 25, 2021 at 10:14:43PM +0300, Anastasia Lubennikova wrote:
1) Could you please clarify, what do you mean by REVOKE failures?
I tried following example:
Start 9.6 cluster.
REVOKE ALL ON function pg_switch_xlog() FROM public;
REVOKE ALL ON function pg_switch_xlog() FROM backup;The upgrade to the current master passes with and without patch.
It seems that current implementation of pg_upgrade doesn't take into account
revoke ACLs.I think you can observe it by adding "revoke all on function
pg_stat_get_subscription from public;" to test_add_acl_to_catalog_objects.sql
and then rerunning your test script. pg_dump will reproduce that REVOKE,
which would fail if postgresql.org had removed that function. That's fine, so
long as a comment mentions the limitation.In the updated patch, I implemented generation of both GRANT ALL and REVOKE
ALL for problematic objects. If I understand it correctly, these calls will
clean object's ACL completely. And I see no harm in doing this, because the
objects don't exist in the new cluster anyway.To test it I attempted to reproduce the problem, using attached
test_revoke.sql in the test. Still, pg_upgrade works fine without any
adjustments. I'd be grateful if you test it some more.test_revoke.sql has "revoke all on function pg_stat_get_subscription() from
test", which does nothing. You need something that causes a REVOKE in pg_dump
output. Worked example:
...
It took a while to debug new version.
Now it detects and fixes both GRANT and REVOKE privileges on the catalog
objects.
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachments:
pg_upgrade_ACL_check_v14.patchtext/x-patch; charset=UTF-8; name=pg_upgrade_ACL_check_v14.patchDownload
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 43fc297eb6..f2d593f574 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -16,6 +16,7 @@
static void check_new_cluster_is_empty(void);
static void check_databases_are_compatible(void);
+static void check_for_changed_signatures(void);
static void check_locale_and_encoding(DbInfo *olddb, DbInfo *newdb);
static bool equivalent_locale(int category, const char *loca, const char *locb);
static void check_is_install_user(ClusterInfo *cluster);
@@ -151,6 +152,8 @@ check_and_dump_old_cluster(bool live_check)
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
new_9_0_populate_pg_largeobject_metadata(&old_cluster, true);
+ get_non_default_acl_infos(&old_cluster);
+
/*
* While not a check option, we do this now because this is the only time
* the old server is running.
@@ -170,6 +173,7 @@ check_new_cluster(void)
check_new_cluster_is_empty();
check_databases_are_compatible();
+ check_for_changed_signatures();
check_loadable_libraries();
@@ -328,6 +332,249 @@ check_cluster_compatibility(bool live_check)
"the old and new port numbers must be different.\n");
}
+/*
+ * check_for_changed_signatures()
+ *
+ * Check that the old cluster doesn't have non-default ACLs for system
+ * objects, which have different signatures in the new cluster,
+ * because they can cause failure during pg_restore stage of
+ * the upgrade process.
+ *
+ * If such objects exist generate fix_system_objects_ACL.sql script
+ * to adjust ACLs before upgrade.
+ *
+ * Currently supported object types are
+ * - table, view, sequence
+ * - table column, view column
+ * - procedure, function, aggregate
+ * - type, domain.
+ */
+static void
+check_for_changed_signatures(void)
+{
+ PGconn *conn;
+ char subquery[QUERY_ALLOC];
+ PGresult *res;
+ int ntups;
+ int i_obj_ident;
+ int dbnum;
+ bool need_check = false;
+ FILE *script = NULL;
+ bool found_changed = false;
+ char output_path[MAXPGPATH];
+
+ if (GET_MAJOR_VERSION(old_cluster.major_version) < 906)
+ return;
+
+ prep_status("Checking for system objects with non-default ACL");
+
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ if (old_cluster.dbarr.dbs[dbnum].non_def_acl_arr.nacls > 0)
+ {
+ need_check = true;
+ break;
+ }
+
+ /*
+ * The old cluster doesn't have system objects with non-default ACL,
+ * so exit quickly.
+ */
+ if (!need_check)
+ {
+ check_ok();
+ return;
+ }
+
+ snprintf(output_path, sizeof(output_path), "fix_system_objects_ACL.sql");
+
+ conn = connectToServer(&new_cluster, "template1");
+
+
+ /* Gather the list of system objects' identities in a new cluster */
+
+ snprintf(subquery, sizeof(subquery),
+ /* Get system relations */
+ "SELECT 'pg_class'::regclass classid, oid objid, 0 objsubid "
+ "FROM pg_catalog.pg_class "
+ "WHERE relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system table columns, view columns */
+ "SELECT 'pg_class'::regclass, att.attrelid, att.attnum "
+ "FROM pg_catalog.pg_class rel "
+ "INNER JOIN pg_catalog.pg_attribute att ON rel.oid = att.attrelid "
+ "WHERE rel.relnamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system functions and procedures */
+ "SELECT 'pg_proc'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_proc "
+ "WHERE pronamespace = 'pg_catalog'::regnamespace "
+ "UNION ALL "
+ /* Get system types and domains */
+ "SELECT 'pg_type'::regclass, oid, 0 "
+ "FROM pg_catalog.pg_type "
+ "WHERE typnamespace = 'pg_catalog'::regnamespace "
+ );
+
+ res = executeQueryOrDie(conn,
+ "SELECT ident.type, ident.identity "
+ "FROM (%s) obj, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " obj.classid, obj.objid, obj.objsubid) ident "
+ /*
+ * Don't rely on database collation, since we use strcmp
+ * comparison to find non-default ACLs.
+ */
+ "ORDER BY ident.identity COLLATE \"C\";", subquery);
+
+ ntups = PQntuples(res);
+
+ i_obj_ident = PQfnumber(res, "identity");
+
+ /* For every database check system objects with non-default ACL. */
+ for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &old_cluster.dbarr.dbs[dbnum];
+ bool db_used = false;
+ int aclnum = 0,
+ objnum = 0;
+
+ /*
+ *
+ * AclInfo array is sorted by obj_ident. This allows us to compare
+ * AclInfo entries with the query result above efficiently.
+ */
+ for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++)
+ {
+ AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum];
+ bool report = false;
+
+ while (objnum < ntups)
+ {
+ int ret;
+
+ ret = strcmp(aclinfo->obj_ident,
+ PQgetvalue(res, objnum, i_obj_ident));
+
+ /*
+ * The new cluster doesn't have an object with same identity,
+ * exit the loop, report below and check next object.
+ */
+ if (ret < 0)
+ {
+ report = true;
+ break;
+ }
+ /*
+ * The new cluster has an object with same identity, just exit
+ * the loop.
+ */
+ else if (ret == 0)
+ {
+ objnum++;
+ break;
+ }
+ else
+ objnum++;
+ }
+
+ /* Generate GRANT/REVOKE statemets for the found objects */
+ if (report)
+ {
+ PQExpBufferData acl_buf;
+
+ found_changed = true;
+ if (script == NULL &&
+ (script = fopen_priv(output_path, "w")) == NULL)
+ pg_fatal("could not open file \"%s\": %m\n", output_path);
+
+ /* append connect database command */
+ if (!db_used)
+ {
+ PQExpBufferData conn_buf;
+
+ initPQExpBuffer(&conn_buf);
+ appendPsqlMetaConnect(&conn_buf, dbinfo->db_name);
+ fputs(conn_buf.data, script);
+ termPQExpBuffer(&conn_buf);
+
+ db_used = true;
+ }
+
+
+ initPQExpBuffer(&acl_buf);
+ /*
+ * To handle both GRANT AND REVOKE ACLs we generate two
+ * statements, which will clean object's ACL. Since the
+ * object do not exist in the new cluster, this action
+ * causes no harm.
+ */
+ appendPQExpBuffer(&acl_buf, " GRANT ALL ");
+ if (strstr(aclinfo->obj_type, "column"))
+ appendPQExpBuffer(&acl_buf, " (%s) ",
+ fmtId(aclinfo->obj_name));
+ appendPQExpBuffer(&acl_buf, " ON");
+ if (!aclinfo->is_relation)
+ appendPQExpBuffer(&acl_buf, " %s ", aclinfo->obj_type);
+
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ {
+ appendPQExpBuffer(&acl_buf, " %s.",
+ fmtId(aclinfo->obj_namespace));
+ appendPQExpBuffer(&acl_buf, "%s ",
+ fmtId(aclinfo->obj_parent_name));
+ }
+ else
+ appendPQExpBuffer(&acl_buf, " %s ",
+ aclinfo->obj_ident);
+ appendPQExpBuffer(&acl_buf, " TO %s ;\n",
+ aclinfo->role_names);
+
+ appendPQExpBuffer(&acl_buf, " REVOKE ALL ");
+ if (strstr(aclinfo->obj_type, "column"))
+ appendPQExpBuffer(&acl_buf, " (%s) ",
+ fmtId(aclinfo->obj_name));
+ appendPQExpBuffer(&acl_buf, " ON");
+ if (!aclinfo->is_relation)
+ appendPQExpBuffer(&acl_buf, " %s ", aclinfo->obj_type);
+ if (strstr(aclinfo->obj_type, "column") != NULL)
+ {
+ appendPQExpBuffer(&acl_buf, " %s.",
+ fmtId(aclinfo->obj_namespace));
+ appendPQExpBuffer(&acl_buf, "%s ",
+ fmtId(aclinfo->obj_parent_name));
+ }
+ else
+ appendPQExpBuffer(&acl_buf, " %s ",
+ aclinfo->obj_ident);
+ appendPQExpBuffer(&acl_buf, " FROM %s ;\n",
+ aclinfo->role_names);
+
+ fputs(acl_buf.data, script);
+ termPQExpBuffer(&acl_buf);
+ }
+ }
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ if (script)
+ fclose(script);
+
+ if (found_changed)
+ {
+ pg_log(PG_REPORT, "fatal\n");
+ pg_fatal("Your installation contains non-default privileges for system objects\n"
+ "for which the API has changed. To perform the upgrade, reset these\n"
+ "privileges to default. The file\n"
+ " %s\n"
+ "when executed by psql will revoke non-default privileges for those objects.\n\n",
+ output_path);
+ }
+ else
+ check_ok();
+}
+
/*
* check_locale_and_encoding()
diff --git a/src/bin/pg_upgrade/info.c b/src/bin/pg_upgrade/info.c
index 5d9a26cf82..0c6714e6b7 100644
--- a/src/bin/pg_upgrade/info.c
+++ b/src/bin/pg_upgrade/info.c
@@ -11,6 +11,7 @@
#include "access/transam.h"
#include "catalog/pg_class_d.h"
+#include "fe_utils/string_utils.h"
#include "pg_upgrade.h"
static void create_rel_filename_map(const char *old_data, const char *new_data,
@@ -23,6 +24,7 @@ static void free_db_and_rel_infos(DbInfoArr *db_arr);
static void get_db_infos(ClusterInfo *cluster);
static void get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo);
static void free_rel_infos(RelInfoArr *rel_arr);
+static void free_acl_infos(AclInfoArr *acl_arr);
static void print_db_infos(DbInfoArr *dbinfo);
static void print_rel_infos(RelInfoArr *rel_arr);
@@ -328,6 +330,143 @@ get_db_and_rel_infos(ClusterInfo *cluster)
}
+/*
+ * get_non_default_acl_infos()
+ *
+ * Fill AclInfo array with information about system objects that
+ * have non-default ACL.
+ * Non-default privileges granted to default
+ * roles are not handled here, because such roles are pinned and
+ * dependencies between them and objects are not tracked.
+ *
+ * Currently supported object types are
+ * - table, view, sequence
+ * - table column, view column
+ * - procedure, function, aggregate
+ * - type, domain.
+ *
+ * Note: the resulting AclInfo array is assumed to be sorted by identity.
+ */
+void
+get_non_default_acl_infos(ClusterInfo *cluster)
+{
+ int dbnum;
+
+ for (dbnum = 0; dbnum < cluster->dbarr.ndbs; dbnum++)
+ {
+ DbInfo *dbinfo = &cluster->dbarr.dbs[dbnum];
+ PGconn *conn = connectToServer(cluster, dbinfo->db_name);
+ PGresult *res;
+ AclInfo *aclinfos = NULL;
+ AclInfo *curr = NULL;
+ int nacls = 0,
+ size_acls = 8;
+ int aclnum = 0;
+ int i_obj_type,
+ i_obj_ident,
+ i_obj_namespace,
+ i_obj_parent_name,
+ i_obj_name,
+ i_rolname,
+ i_is_relation;
+
+ res = executeQueryOrDie(conn,
+ /*
+ * Get system objects with non-default ACLs.
+ */
+ "SELECT obj.type, obj.identity, "
+ " obj_as_address.object_names[1] as namespace, "
+ " obj_as_address.object_names[2] as parent_name, "
+ " obj_as_address.object_names[array_length(object_names, 1)] "
+ " as name, shd.refobjid::regrole rolename, "
+ " CASE WHEN shd.classid = 'pg_class'::regclass THEN true "
+ " ELSE false "
+ " END is_relation "
+ "FROM pg_catalog.pg_shdepend shd, "
+ "LATERAL pg_catalog.pg_identify_object("
+ " shd.classid, shd.objid, shd.objsubid) obj, "
+ " pg_catalog.pg_identify_object_as_address("
+ " shd.classid, shd.objid, shd.objsubid) obj_as_address "
+ /* 'a' is for SHARED_DEPENDENCY_ACL */
+ "WHERE shd.deptype = 'a' AND shd.dbid = %d "
+ " AND shd.refclassid = 'pg_authid'::regclass::oid "
+ " AND shd.classid IN ('pg_proc'::regclass, "
+ " 'pg_class'::regclass, 'pg_type'::regclass) "
+ /* get only system objects */
+ " AND obj.schema = 'pg_catalog' "
+ /*
+ * Sort only by identity. It should be enough to uniquely compare
+ * objects later in check_for_changed_signatures().
+ * Don't rely on database collation, since we use strcmp
+ * comparison below.
+ */
+ "ORDER BY obj.identity COLLATE \"C\";", dbinfo->db_oid);
+
+ i_obj_type = PQfnumber(res, "type");
+ i_obj_ident = PQfnumber(res, "identity");
+ i_obj_namespace = PQfnumber(res, "namespace");
+ i_obj_parent_name = PQfnumber(res, "parent_name");
+ i_obj_name = PQfnumber(res, "name");
+ i_rolname = PQfnumber(res, "rolename");
+ i_is_relation = PQfnumber(res, "is_relation");
+
+ aclinfos = (AclInfo *) pg_malloc(sizeof(AclInfo) * size_acls);
+
+ while (aclnum < PQntuples(res))
+ {
+ PQExpBuffer roles_buf;
+
+ if (nacls == size_acls)
+ {
+ size_acls *= 2;
+ aclinfos = (AclInfo *) pg_realloc(aclinfos,
+ sizeof(AclInfo) * size_acls);
+ }
+ curr = &aclinfos[nacls++];
+
+ curr->obj_type = pg_strdup(PQgetvalue(res, aclnum, i_obj_type));
+ curr->obj_ident = pg_strdup(PQgetvalue(res, aclnum, i_obj_ident));
+ curr->obj_namespace = pg_strdup(PQgetvalue(res, aclnum,
+ i_obj_namespace));
+ curr->obj_parent_name = pg_strdup(PQgetvalue(res, aclnum,
+ i_obj_parent_name));
+ curr->obj_name = pg_strdup(PQgetvalue(res, aclnum, i_obj_name));
+ curr->is_relation =
+ PQgetvalue(res, aclnum, i_is_relation)[0] == 't';
+
+ roles_buf = createPQExpBuffer();
+ initPQExpBuffer(roles_buf);
+
+ /*
+ * For each object gather string of role names mentioned in ACL
+ * in a format convenient for further use
+ * in GRANT/REVOKE statement.
+ */
+ while (aclnum < PQntuples(res) &&
+ strcmp(curr->obj_ident,
+ PQgetvalue(res, aclnum, i_obj_ident)) == 0)
+ {
+ if (roles_buf->len != 0)
+ appendPQExpBufferChar(roles_buf, ',');
+
+ appendPQExpBufferStr(roles_buf,
+ quote_identifier(PQgetvalue(res, aclnum, i_rolname)));
+ aclnum++;
+ }
+
+ curr->role_names = pg_strdup(roles_buf->data);
+ destroyPQExpBuffer(roles_buf);
+ }
+
+ PQclear(res);
+ PQfinish(conn);
+
+ dbinfo->non_def_acl_arr.aclinfos = aclinfos;
+ dbinfo->non_def_acl_arr.nacls = nacls;
+ }
+}
+
+
/*
* get_db_infos()
*
@@ -384,6 +523,10 @@ get_db_infos(ClusterInfo *cluster)
dbinfos[tupnum].db_ctype = pg_strdup(PQgetvalue(res, tupnum, i_datctype));
snprintf(dbinfos[tupnum].db_tablespace, sizeof(dbinfos[tupnum].db_tablespace), "%s",
PQgetvalue(res, tupnum, i_spclocation));
+
+ /* initialize clean array */
+ dbinfos[tupnum].non_def_acl_arr.nacls = 0;
+ dbinfos[tupnum].non_def_acl_arr.aclinfos = NULL;
}
PQclear(res);
@@ -595,6 +738,9 @@ free_db_and_rel_infos(DbInfoArr *db_arr)
for (dbnum = 0; dbnum < db_arr->ndbs; dbnum++)
{
free_rel_infos(&db_arr->dbs[dbnum].rel_arr);
+
+ if (&db_arr->dbs[dbnum].non_def_acl_arr.nacls > 0)
+ free_acl_infos(&db_arr->dbs[dbnum].non_def_acl_arr);
pg_free(db_arr->dbs[dbnum].db_name);
}
pg_free(db_arr->dbs);
@@ -620,6 +766,23 @@ free_rel_infos(RelInfoArr *rel_arr)
rel_arr->nrels = 0;
}
+static void
+free_acl_infos(AclInfoArr *acl_arr)
+{
+ int aclnum;
+
+ for (aclnum = 0; aclnum < acl_arr->nacls; aclnum++)
+ {
+ pg_free(acl_arr->aclinfos[aclnum].obj_type);
+ pg_free(acl_arr->aclinfos[aclnum].obj_ident);
+ pg_free(acl_arr->aclinfos[aclnum].role_names);
+ }
+
+ pg_free(acl_arr->aclinfos);
+ acl_arr->aclinfos = NULL;
+ acl_arr->nacls = 0;
+}
+
static void
print_db_infos(DbInfoArr *db_arr)
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 919a7849fd..32e305ae00 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -147,6 +147,36 @@ typedef struct
int nrels;
} RelInfoArr;
+/*
+ * Information about database object needed to check
+ * if its signature has changed between versions.
+ * We need it to generate a statement to adjust privileges
+ * if necessary.
+ */
+typedef struct
+{
+ char *obj_type; /* object type */
+ char *obj_ident; /* complete object identity */
+
+ /* object namespace, parent name (table name for 'column' objects)
+ * and name. Store them separately from identity to simplify
+ * parsing and qouting.
+ */
+ char *obj_namespace;
+ char *obj_parent_name;
+ char *obj_name;
+
+ bool is_relation; /* if the object is relation */
+ char *role_names; /* list of role names which have permissions
+ * on the object */
+} AclInfo;
+
+typedef struct
+{
+ AclInfo *aclinfos;
+ int nacls;
+} AclInfoArr;
+
/*
* The following structure represents a relation mapping.
*/
@@ -183,6 +213,8 @@ typedef struct
char *db_ctype;
int db_encoding;
RelInfoArr rel_arr; /* array of all user relinfos */
+ AclInfoArr non_def_acl_arr; /* array of objects info with non default
+ * ACL */
} DbInfo;
typedef struct
@@ -389,6 +421,7 @@ FileNameMap *gen_db_file_maps(DbInfo *old_db,
DbInfo *new_db, int *nmaps, const char *old_pgdata,
const char *new_pgdata);
void get_db_and_rel_infos(ClusterInfo *cluster);
+void get_non_default_acl_infos(ClusterInfo *cluster);
void print_maps(FileNameMap *maps, int n,
const char *db_name);
test_rename_catalog_objects_v14text/plain; charset=UTF-8; name=test_rename_catalog_objects_v14Download
commit 175f89113e1f1fb4f84f534b9055bfd37240189c
Author: anastasia <a.lubennikova@postgrespro.ru>
Date: Thu Feb 11 18:37:43 2021 +0300
test
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 70bc2123df..94d072f51d 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -40,7 +40,7 @@ OBJS = \
pg_publication.o \
pg_range.o \
pg_shdepend.o \
- pg_subscription.o \
+ pg_sub.o \
pg_type.o \
storage.o \
toasting.o
@@ -67,8 +67,8 @@ CATALOG_HEADERS := \
pg_foreign_table.h pg_policy.h pg_replication_origin.h \
pg_default_acl.h pg_init_privs.h pg_seclabel.h pg_shseclabel.h \
pg_collation.h pg_partitioned_table.h pg_range.h pg_transform.h \
- pg_sequence.h pg_publication.h pg_publication_rel.h pg_subscription.h \
- pg_subscription_rel.h
+ pg_sequence.h pg_publication.h pg_publication_rel.h pg_sub.h \
+ pg_sub_rel.h
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h system_fk_info.h
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index add3d147e7..ac2cfe690e 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -50,7 +50,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
@@ -5267,7 +5267,7 @@ pg_publication_ownercheck(Oid pub_oid, Oid roleid)
* Ownership check for a subscription (specified by OID).
*/
bool
-pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
+pg_sub_ownercheck(Oid sub_oid, Oid roleid)
{
HeapTuple tuple;
Oid ownerId;
@@ -5282,7 +5282,7 @@ pg_subscription_ownercheck(Oid sub_oid, Oid roleid)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription with OID %u does not exist", sub_oid)));
- ownerId = ((Form_pg_subscription) GETSTRUCT(tuple))->subowner;
+ ownerId = ((Form_pg_sub) GETSTRUCT(tuple))->subowner;
ReleaseSysCache(tuple);
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index e2ed80a5de..95257d5db7 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -36,7 +36,7 @@
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 1325733624..1cb415658b 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 9abc4a1f55..f03f25bd56 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -56,7 +56,7 @@
#include "catalog/pg_opclass.h"
#include "catalog/pg_partitioned_table.h"
#include "catalog/pg_statistic.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/storage.h"
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 4907855043..aef3bf7f03 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -42,7 +42,7 @@ SET search_path TO information_schema;
/* Expand any 1-D array into a set with integers 1..N */
CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
RETURNS SETOF RECORD
- LANGUAGE sql STRICT IMMUTABLE PARALLEL SAFE
+ LANGUAGE sqltest STRICT IMMUTABLE PARALLEL SAFE
AS 'select $1[s], s - pg_catalog.array_lower($1,1) + 1
from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
pg_catalog.array_upper($1,1),
@@ -51,7 +51,7 @@ CREATE FUNCTION _pg_expandarray(IN anyarray, OUT x anyelement, OUT n int)
/* Given an index's OID and an underlying-table column number, return the
* column's position in the index (NULL if not there) */
CREATE FUNCTION _pg_index_position(oid, smallint) RETURNS int
- LANGUAGE sql STRICT STABLE
+ LANGUAGE sqltest STRICT STABLE
AS $$
SELECT (ss.a).n FROM
(SELECT information_schema._pg_expandarray(indkey) AS a
@@ -60,7 +60,7 @@ SELECT (ss.a).n FROM
$$;
CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -68,7 +68,7 @@ CREATE FUNCTION _pg_truetypid(pg_attribute, pg_type) RETURNS oid
$$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typbasetype ELSE $1.atttypid END$$;
CREATE FUNCTION _pg_truetypmod(pg_attribute, pg_type) RETURNS int4
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -78,7 +78,7 @@ $$SELECT CASE WHEN $2.typtype = 'd' THEN $2.typtypmod ELSE $1.atttypmod END$$;
-- these functions encapsulate knowledge about the encoding of typmod:
CREATE FUNCTION _pg_char_max_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -94,7 +94,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_char_octet_length(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -110,7 +110,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -131,7 +131,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_precision_radix(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -143,7 +143,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_numeric_scale(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -159,7 +159,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_datetime_precision(typid oid, typmod int4) RETURNS integer
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -175,7 +175,7 @@ $$SELECT
END$$;
CREATE FUNCTION _pg_interval_type(typid oid, mod int4) RETURNS text
- LANGUAGE sql
+ LANGUAGE sqltest
IMMUTABLE
PARALLEL SAFE
RETURNS NULL ON NULL INPUT
@@ -1477,7 +1477,7 @@ CREATE VIEW routines AS
CAST(null AS cardinal_number) AS maximum_cardinality,
CAST(CASE WHEN p.prokind <> 'p' THEN 0 END AS sql_identifier) AS dtd_identifier,
- CAST(CASE WHEN l.lanname = 'sql' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
+ CAST(CASE WHEN l.lanname = 'sqltest' THEN 'SQL' ELSE 'EXTERNAL' END AS character_data)
AS routine_body,
CAST(
CASE WHEN pg_has_role(p.proowner, 'USAGE') THEN p.prosrc ELSE null END
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 6d88b690d8..dfd2a4128f 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -51,7 +51,7 @@
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_trigger.h"
@@ -579,10 +579,10 @@ static const ObjectPropertyType ObjectProperty[] =
SubscriptionObjectIndexId,
SUBSCRIPTIONOID,
SUBSCRIPTIONNAME,
- Anum_pg_subscription_oid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_oid,
+ Anum_pg_sub_subname,
InvalidAttrNumber,
- Anum_pg_subscription_subowner,
+ Anum_pg_sub_subowner,
InvalidAttrNumber,
OBJECT_SUBSCRIPTION,
true
@@ -2510,7 +2510,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
strVal((Value *) object));
break;
case OBJECT_SUBSCRIPTION:
- if (!pg_subscription_ownercheck(address.objectId, roleid))
+ if (!pg_sub_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, objtype,
strVal((Value *) object));
break;
diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c
index 90b7a5de29..8e2bd02dcb 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -40,7 +40,7 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_sub.c
similarity index 83%
rename from src/backend/catalog/pg_subscription.c
rename to src/backend/catalog/pg_sub.c
index 44cb285b68..669975641d 100644
--- a/src/backend/catalog/pg_subscription.c
+++ b/src/backend/catalog/pg_sub.c
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
- * pg_subscription.c
+ * pg_sub.c
* replication subscriptions
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * src/backend/catalog/pg_subscription.c
+ * src/backend/catalog/pg_sub.c
*
*-------------------------------------------------------------------------
*/
@@ -20,8 +20,8 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/indexing.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
@@ -43,7 +43,7 @@ GetSubscription(Oid subid, bool missing_ok)
{
HeapTuple tup;
Subscription *sub;
- Form_pg_subscription subform;
+ Form_pg_sub subform;
Datum datum;
bool isnull;
@@ -57,21 +57,21 @@ GetSubscription(Oid subid, bool missing_ok)
elog(ERROR, "cache lookup failed for subscription %u", subid);
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = (Form_pg_sub) GETSTRUCT(tup);
sub = (Subscription *) palloc(sizeof(Subscription));
sub->oid = subid;
sub->dbid = subform->subdbid;
sub->name = pstrdup(NameStr(subform->subname));
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->binary = subform->subbinary;
sub->stream = subform->substream;
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subconninfo,
+ Anum_pg_sub_subconninfo,
&isnull);
Assert(!isnull);
sub->conninfo = TextDatumGetCString(datum);
@@ -79,7 +79,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subslotname,
+ Anum_pg_sub_subslotname,
&isnull);
if (!isnull)
sub->slotname = pstrdup(NameStr(*DatumGetName(datum)));
@@ -89,7 +89,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get synccommit */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subsynccommit,
+ Anum_pg_sub_subsynccommit,
&isnull);
Assert(!isnull);
sub->synccommit = TextDatumGetCString(datum);
@@ -97,7 +97,7 @@ GetSubscription(Oid subid, bool missing_ok)
/* Get publications */
datum = SysCacheGetAttr(SUBSCRIPTIONOID,
tup,
- Anum_pg_subscription_subpublications,
+ Anum_pg_sub_subpublications,
&isnull);
Assert(!isnull);
sub->publications = textarray_to_stringlist(DatumGetArrayTypeP(datum));
@@ -123,7 +123,7 @@ CountDBSubscriptions(Oid dbid)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
ScanKeyInit(&scankey,
- Anum_pg_subscription_subdbid,
+ Anum_pg_sub_subdbid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(dbid));
@@ -165,7 +165,7 @@ get_subscription_oid(const char *subname, bool missing_ok)
{
Oid oid;
- oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ oid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(subname));
if (!OidIsValid(oid) && !missing_ok)
ereport(ERROR,
@@ -185,7 +185,7 @@ get_subscription_name(Oid subid, bool missing_ok)
{
HeapTuple tup;
char *subname;
- Form_pg_subscription subform;
+ Form_pg_sub subform;
tup = SearchSysCache1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
@@ -196,7 +196,7 @@ get_subscription_name(Oid subid, bool missing_ok)
return NULL;
}
- subform = (Form_pg_subscription) GETSTRUCT(tup);
+ subform = (Form_pg_sub) GETSTRUCT(tup);
subname = pstrdup(NameStr(subform->subname));
ReleaseSysCache(tup);
@@ -239,8 +239,8 @@ AddSubscriptionRelState(Oid subid, Oid relid, char state,
{
Relation rel;
HeapTuple tup;
- bool nulls[Natts_pg_subscription_rel];
- Datum values[Natts_pg_subscription_rel];
+ bool nulls[Natts_pg_sub_rel];
+ Datum values[Natts_pg_sub_rel];
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
@@ -257,13 +257,13 @@ AddSubscriptionRelState(Oid subid, Oid relid, char state,
/* Form the tuple. */
memset(values, 0, sizeof(values));
memset(nulls, false, sizeof(nulls));
- values[Anum_pg_subscription_rel_srsubid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_rel_srrelid - 1] = ObjectIdGetDatum(relid);
- values[Anum_pg_subscription_rel_srsubstate - 1] = CharGetDatum(state);
+ values[Anum_pg_sub_rel_srsubid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_rel_srrelid - 1] = ObjectIdGetDatum(relid);
+ values[Anum_pg_sub_rel_srsubstate - 1] = CharGetDatum(state);
if (sublsn != InvalidXLogRecPtr)
- values[Anum_pg_subscription_rel_srsublsn - 1] = LSNGetDatum(sublsn);
+ values[Anum_pg_sub_rel_srsublsn - 1] = LSNGetDatum(sublsn);
else
- nulls[Anum_pg_subscription_rel_srsublsn - 1] = true;
+ nulls[Anum_pg_sub_rel_srsublsn - 1] = true;
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -285,9 +285,9 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
{
Relation rel;
HeapTuple tup;
- bool nulls[Natts_pg_subscription_rel];
- Datum values[Natts_pg_subscription_rel];
- bool replaces[Natts_pg_subscription_rel];
+ bool nulls[Natts_pg_sub_rel];
+ Datum values[Natts_pg_sub_rel];
+ bool replaces[Natts_pg_sub_rel];
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
@@ -306,14 +306,14 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
memset(nulls, false, sizeof(nulls));
memset(replaces, false, sizeof(replaces));
- replaces[Anum_pg_subscription_rel_srsubstate - 1] = true;
- values[Anum_pg_subscription_rel_srsubstate - 1] = CharGetDatum(state);
+ replaces[Anum_pg_sub_rel_srsubstate - 1] = true;
+ values[Anum_pg_sub_rel_srsubstate - 1] = CharGetDatum(state);
- replaces[Anum_pg_subscription_rel_srsublsn - 1] = true;
+ replaces[Anum_pg_sub_rel_srsublsn - 1] = true;
if (sublsn != InvalidXLogRecPtr)
- values[Anum_pg_subscription_rel_srsublsn - 1] = LSNGetDatum(sublsn);
+ values[Anum_pg_sub_rel_srsublsn - 1] = LSNGetDatum(sublsn);
else
- nulls[Anum_pg_subscription_rel_srsublsn - 1] = true;
+ nulls[Anum_pg_sub_rel_srsublsn - 1] = true;
tup = heap_modify_tuple(tup, RelationGetDescr(rel), values, nulls,
replaces);
@@ -350,11 +350,11 @@ GetSubscriptionRelState(Oid subid, Oid relid, XLogRecPtr *sublsn)
}
/* Get the state. */
- substate = ((Form_pg_subscription_rel) GETSTRUCT(tup))->srsubstate;
+ substate = ((Form_pg_sub_rel) GETSTRUCT(tup))->srsubstate;
/* Get the LSN */
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
- Anum_pg_subscription_rel_srsublsn, &isnull);
+ Anum_pg_sub_rel_srsublsn, &isnull);
if (isnull)
*sublsn = InvalidXLogRecPtr;
else
@@ -384,7 +384,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
if (OidIsValid(subid))
{
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srsubid,
BTEqualStrategyNumber,
F_OIDEQ,
ObjectIdGetDatum(subid));
@@ -393,7 +393,7 @@ RemoveSubscriptionRel(Oid subid, Oid relid)
if (OidIsValid(relid))
{
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srrelid,
+ Anum_pg_sub_rel_srrelid,
BTEqualStrategyNumber,
F_OIDEQ,
ObjectIdGetDatum(relid));
@@ -429,7 +429,7 @@ GetSubscriptionRelations(Oid subid)
rel = table_open(SubscriptionRelRelationId, AccessShareLock);
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srsubid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(subid));
@@ -438,18 +438,18 @@ GetSubscriptionRelations(Oid subid)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_subscription_rel subrel;
+ Form_pg_sub_rel subrel;
SubscriptionRelState *relstate;
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = (Form_pg_sub_rel) GETSTRUCT(tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
- Anum_pg_subscription_rel_srsublsn, &isnull);
+ Anum_pg_sub_rel_srsublsn, &isnull);
if (isnull)
relstate->lsn = InvalidXLogRecPtr;
else
@@ -483,12 +483,12 @@ GetSubscriptionNotReadyRelations(Oid subid)
rel = table_open(SubscriptionRelRelationId, AccessShareLock);
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srsubid,
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(subid));
ScanKeyInit(&skey[nkeys++],
- Anum_pg_subscription_rel_srsubstate,
+ Anum_pg_sub_rel_srsubstate,
BTEqualStrategyNumber, F_CHARNE,
CharGetDatum(SUBREL_STATE_READY));
@@ -497,18 +497,18 @@ GetSubscriptionNotReadyRelations(Oid subid)
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- Form_pg_subscription_rel subrel;
+ Form_pg_sub_rel subrel;
SubscriptionRelState *relstate;
Datum d;
bool isnull;
- subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
+ subrel = (Form_pg_sub_rel) GETSTRUCT(tup);
relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
relstate->relid = subrel->srrelid;
relstate->state = subrel->srsubstate;
d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
- Anum_pg_subscription_rel_srsublsn, &isnull);
+ Anum_pg_sub_rel_srsublsn, &isnull);
if (isnull)
relstate->lsn = InvalidXLogRecPtr;
else
diff --git a/src/backend/catalog/sql_features.txt b/src/backend/catalog/sql_features.txt
index 86519ad297..0db61dfb85 100644
--- a/src/backend/catalog/sql_features.txt
+++ b/src/backend/catalog/sql_features.txt
@@ -28,7 +28,7 @@ B124 Routine language Fortran NO
B125 Routine language MUMPS NO
B126 Routine language Pascal NO
B127 Routine language PL/I NO
-B128 Routine language SQL NO
+B128 Routine LANGUAGE SQLTEST NO
B200 Polymorphic table functions NO
B201 More than one PTF generic table parameter NO
B202 PTF Copartitioning NO
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index fa58afd9d7..6eb18cbde2 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -478,7 +478,7 @@ SELECT
l.provider, l.label
FROM
pg_shseclabel l
- JOIN pg_subscription s ON l.classoid = s.tableoid AND l.objoid = s.oid
+ JOIN pg_sub s ON l.classoid = s.tableoid AND l.objoid = s.oid
UNION ALL
SELECT
l.objoid, l.classoid, 0::int4 AS objsubid,
@@ -832,7 +832,7 @@ CREATE VIEW pg_stat_wal_receiver AS
s.received_tli,
s.last_msg_send_time,
s.last_msg_receipt_time,
- s.latest_end_lsn,
+ s.latest_end_location,
s.latest_end_time,
s.slot_name,
s.sender_host,
@@ -841,7 +841,7 @@ CREATE VIEW pg_stat_wal_receiver AS
FROM pg_stat_get_wal_receiver() s
WHERE s.pid IS NOT NULL;
-CREATE VIEW pg_stat_subscription AS
+CREATE VIEW pg_stat_sub AS
SELECT
su.oid AS subid,
su.subname,
@@ -850,10 +850,10 @@ CREATE VIEW pg_stat_subscription AS
st.received_lsn,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_location,
st.latest_end_time
- FROM pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL) st
+ FROM pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL) st
ON (st.subid = su.oid);
CREATE VIEW pg_stat_ssl AS
@@ -1165,10 +1165,10 @@ CREATE VIEW pg_replication_origin_status AS
REVOKE ALL ON pg_replication_origin_status FROM public;
--- All columns of pg_subscription except subconninfo are readable.
-REVOKE ALL ON pg_subscription FROM public;
-GRANT SELECT (subdbid, subname, subowner, subenabled, subbinary, substream, subslotname, subpublications)
- ON pg_subscription TO public;
+-- All columns of pg_sub except subconninfo are readable.
+REVOKE ALL ON pg_sub FROM public;
+GRANT SELECT (subdbid, subname, subowner, subactive, subbinary, substream, subslotname, subpublications)
+ ON pg_sub TO public;
--
@@ -1218,7 +1218,7 @@ FROM pg_catalog.ts_parse(
) AS tt
WHERE tt.tokid = parse.tokid
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE SQLTEST STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(regconfig,text) IS
'debug function for text search configuration';
@@ -1234,7 +1234,7 @@ RETURNS SETOF record AS
$$
SELECT * FROM pg_catalog.ts_debug( pg_catalog.get_current_ts_config(), $1);
$$
-LANGUAGE SQL STRICT STABLE PARALLEL SAFE;
+LANGUAGE SQLTEST STRICT STABLE PARALLEL SAFE;
COMMENT ON FUNCTION ts_debug(text) IS
'debug function for current text search configuration';
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 29249498a9..6f3d7fc23c 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -35,7 +35,7 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 2b159b60eb..e44c3b7a97 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -38,7 +38,7 @@
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 5ccbc9dd50..2692818394 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -23,8 +23,8 @@
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h"
@@ -345,8 +345,8 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
Relation rel;
ObjectAddress myself;
Oid subid;
- bool nulls[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
Oid owner = GetUserId();
HeapTuple tup;
bool connect;
@@ -407,7 +407,7 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
/* Check if name is used */
- subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_subscription_oid,
+ subid = GetSysCacheOid2(SUBSCRIPTIONNAME, Anum_pg_sub_oid,
MyDatabaseId, CStringGetDatum(stmt->subname));
if (OidIsValid(subid))
{
@@ -438,25 +438,25 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
memset(nulls, false, sizeof(nulls));
subid = GetNewOidWithIndex(rel, SubscriptionObjectIndexId,
- Anum_pg_subscription_oid);
- values[Anum_pg_subscription_oid - 1] = ObjectIdGetDatum(subid);
- values[Anum_pg_subscription_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
- values[Anum_pg_subscription_subname - 1] =
+ Anum_pg_sub_oid);
+ values[Anum_pg_sub_oid - 1] = ObjectIdGetDatum(subid);
+ values[Anum_pg_sub_subdbid - 1] = ObjectIdGetDatum(MyDatabaseId);
+ values[Anum_pg_sub_subname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(stmt->subname));
- values[Anum_pg_subscription_subowner - 1] = ObjectIdGetDatum(owner);
- values[Anum_pg_subscription_subenabled - 1] = BoolGetDatum(enabled);
- values[Anum_pg_subscription_subbinary - 1] = BoolGetDatum(binary);
- values[Anum_pg_subscription_substream - 1] = BoolGetDatum(streaming);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subowner - 1] = ObjectIdGetDatum(owner);
+ values[Anum_pg_sub_subactive - 1] = BoolGetDatum(enabled);
+ values[Anum_pg_sub_subbinary - 1] = BoolGetDatum(binary);
+ values[Anum_pg_sub_substream - 1] = BoolGetDatum(streaming);
+ values[Anum_pg_sub_subconninfo - 1] =
CStringGetTextDatum(conninfo);
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- values[Anum_pg_subscription_subsynccommit - 1] =
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(publications);
tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
@@ -670,14 +670,14 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
{
Relation rel;
ObjectAddress myself;
- bool nulls[Natts_pg_subscription];
- bool replaces[Natts_pg_subscription];
- Datum values[Natts_pg_subscription];
+ bool nulls[Natts_pg_sub];
+ bool replaces[Natts_pg_sub];
+ Datum values[Natts_pg_sub];
HeapTuple tup;
Oid subid;
bool update_tuple = false;
Subscription *sub;
- Form_pg_subscription form;
+ Form_pg_sub form;
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
@@ -691,11 +691,11 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
errmsg("subscription \"%s\" does not exist",
stmt->subname)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
subid = form->oid;
/* must be owner */
- if (!pg_subscription_ownercheck(subid, GetUserId()))
+ if (!pg_sub_ownercheck(subid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
stmt->subname);
@@ -741,32 +741,32 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
"slot_name = NONE")));
if (slotname)
- values[Anum_pg_subscription_subslotname - 1] =
+ values[Anum_pg_sub_subslotname - 1] =
DirectFunctionCall1(namein, CStringGetDatum(slotname));
else
- nulls[Anum_pg_subscription_subslotname - 1] = true;
- replaces[Anum_pg_subscription_subslotname - 1] = true;
+ nulls[Anum_pg_sub_subslotname - 1] = true;
+ replaces[Anum_pg_sub_subslotname - 1] = true;
}
if (synchronous_commit)
{
- values[Anum_pg_subscription_subsynccommit - 1] =
+ values[Anum_pg_sub_subsynccommit - 1] =
CStringGetTextDatum(synchronous_commit);
- replaces[Anum_pg_subscription_subsynccommit - 1] = true;
+ replaces[Anum_pg_sub_subsynccommit - 1] = true;
}
if (binary_given)
{
- values[Anum_pg_subscription_subbinary - 1] =
+ values[Anum_pg_sub_subbinary - 1] =
BoolGetDatum(binary);
- replaces[Anum_pg_subscription_subbinary - 1] = true;
+ replaces[Anum_pg_sub_subbinary - 1] = true;
}
if (streaming_given)
{
- values[Anum_pg_subscription_substream - 1] =
+ values[Anum_pg_sub_substream - 1] =
BoolGetDatum(streaming);
- replaces[Anum_pg_subscription_substream - 1] = true;
+ replaces[Anum_pg_sub_substream - 1] = true;
}
update_tuple = true;
@@ -795,9 +795,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot enable subscription that does not have a slot name")));
- values[Anum_pg_subscription_subenabled - 1] =
+ values[Anum_pg_sub_subactive - 1] =
BoolGetDatum(enabled);
- replaces[Anum_pg_subscription_subenabled - 1] = true;
+ replaces[Anum_pg_sub_subactive - 1] = true;
if (enabled)
ApplyLauncherWakeupAtCommit();
@@ -812,9 +812,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
/* Check the connection info string. */
walrcv_check_conninfo(stmt->conninfo);
- values[Anum_pg_subscription_subconninfo - 1] =
+ values[Anum_pg_sub_subconninfo - 1] =
CStringGetTextDatum(stmt->conninfo);
- replaces[Anum_pg_subscription_subconninfo - 1] = true;
+ replaces[Anum_pg_sub_subconninfo - 1] = true;
update_tuple = true;
break;
@@ -833,9 +833,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
&refresh,
NULL, NULL, /* no "binary" */
NULL, NULL); /* no "streaming" */
- values[Anum_pg_subscription_subpublications - 1] =
+ values[Anum_pg_sub_subpublications - 1] =
publicationListToArray(stmt->publication);
- replaces[Anum_pg_subscription_subpublications - 1] = true;
+ replaces[Anum_pg_sub_subpublications - 1] = true;
update_tuple = true;
@@ -928,10 +928,10 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
char *err = NULL;
WalReceiverConn *wrconn = NULL;
StringInfoData cmd;
- Form_pg_subscription form;
+ Form_pg_sub form;
/*
- * Lock pg_subscription with AccessExclusiveLock to ensure that the
+ * Lock pg_sub with AccessExclusiveLock to ensure that the
* launcher doesn't restart new worker during dropping the subscription
*/
rel = table_open(SubscriptionRelationId, AccessExclusiveLock);
@@ -956,11 +956,11 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
return;
}
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
subid = form->oid;
/* must be owner */
- if (!pg_subscription_ownercheck(subid, GetUserId()))
+ if (!pg_sub_ownercheck(subid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
stmt->subname);
@@ -975,19 +975,19 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
/* Get subname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subname, &isnull);
+ Anum_pg_sub_subname, &isnull);
Assert(!isnull);
subname = pstrdup(NameStr(*DatumGetName(datum)));
/* Get conninfo */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subconninfo, &isnull);
+ Anum_pg_sub_subconninfo, &isnull);
Assert(!isnull);
conninfo = TextDatumGetCString(datum);
/* Get slotname */
datum = SysCacheGetAttr(SUBSCRIPTIONOID, tup,
- Anum_pg_subscription_subslotname, &isnull);
+ Anum_pg_sub_subslotname, &isnull);
if (!isnull)
slotname = pstrdup(NameStr(*DatumGetName(datum)));
else
@@ -1115,14 +1115,14 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
static void
AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
{
- Form_pg_subscription form;
+ Form_pg_sub form;
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
if (form->subowner == newOwnerId)
return;
- if (!pg_subscription_ownercheck(form->oid, GetUserId()))
+ if (!pg_sub_ownercheck(form->oid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
NameStr(form->subname));
@@ -1156,7 +1156,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
HeapTuple tup;
Relation rel;
ObjectAddress address;
- Form_pg_subscription form;
+ Form_pg_sub form;
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
@@ -1168,7 +1168,7 @@ AlterSubscriptionOwner(const char *name, Oid newOwnerId)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("subscription \"%s\" does not exist", name)));
- form = (Form_pg_subscription) GETSTRUCT(tup);
+ form = (Form_pg_sub) GETSTRUCT(tup);
subid = form->oid;
AlterSubscriptionOwner_internal(rel, tup, newOwnerId);
diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 186514cd9e..8dc6e852f9 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -22,8 +22,8 @@
#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "funcapi.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
@@ -95,7 +95,7 @@ static void logicalrep_worker_cleanup(LogicalRepWorker *worker);
static bool on_commit_launcher_wakeup = false;
-Datum pg_stat_get_subscription(PG_FUNCTION_ARGS);
+Datum pg_stat_get_sub(PG_FUNCTION_ARGS);
/*
@@ -135,7 +135,7 @@ get_subscription_list(void)
while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
{
- Form_pg_subscription subform = (Form_pg_subscription) GETSTRUCT(tup);
+ Form_pg_sub subform = (Form_pg_sub) GETSTRUCT(tup);
Subscription *sub;
MemoryContext oldcxt;
@@ -151,7 +151,7 @@ get_subscription_list(void)
sub->oid = subform->oid;
sub->dbid = subform->subdbid;
sub->owner = subform->subowner;
- sub->enabled = subform->subenabled;
+ sub->enabled = subform->subactive;
sub->name = pstrdup(NameStr(subform->subname));
/* We don't fill fields we are not interested in. */
@@ -927,7 +927,7 @@ AtEOSubXact_ApplyLauncher(bool isCommit, int nestDepth)
*
* This is used to send launcher signal to stop sleeping and process the
* subscriptions when current transaction commits. Should be used when new
- * tuple was added to the pg_subscription catalog.
+ * tuple was added to the pg_sub catalog.
*/
void
ApplyLauncherWakeupAtCommit(void)
@@ -966,7 +966,7 @@ ApplyLauncherMain(Datum main_arg)
/*
* Establish connection to nailed catalogs (we only ever access
- * pg_subscription).
+ * pg_sub).
*/
BackgroundWorkerInitializeConnection(NULL, NULL, 0);
@@ -1072,7 +1072,7 @@ IsLogicalLauncher(void)
* Returns state of the subscriptions.
*/
Datum
-pg_stat_get_subscription(PG_FUNCTION_ARGS)
+pg_stat_get_sub(PG_FUNCTION_ARGS)
{
#define PG_STAT_GET_SUBSCRIPTION_COLS 8
Oid subid = PG_ARGISNULL(0) ? InvalidOid : PG_GETARG_OID(0);
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index e861c0ff80..997a535f0f 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -20,7 +20,7 @@
#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/namespace.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub_rel.h"
#include "executor/executor.h"
#include "nodes/makefuncs.h"
#include "replication/logicalrelation.h"
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index ccbdbcf08f..0249afa7b0 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -91,7 +91,7 @@
#include "access/table.h"
#include "access/xact.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_type.h"
#include "commands/copy.h"
#include "miscadmin.h"
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index eb7db89cef..7c160e6235 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -65,8 +65,8 @@
#include "catalog/namespace.h"
#include "catalog/partition.h"
#include "catalog/pg_inherits.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_tablespace.h"
#include "commands/tablecmds.h"
#include "commands/tablespace.h"
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 723f513d8b..899af845b5 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1311,7 +1311,7 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
TimeLineID received_tli;
TimestampTz last_send_time;
TimestampTz last_receipt_time;
- XLogRecPtr latest_end_lsn;
+ XLogRecPtr latest_end_location;
TimestampTz latest_end_time;
char sender_host[NI_MAXHOST];
int sender_port = 0;
@@ -1330,7 +1330,7 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
received_tli = WalRcv->receivedTLI;
last_send_time = WalRcv->lastMsgSendTime;
last_receipt_time = WalRcv->lastMsgReceiptTime;
- latest_end_lsn = WalRcv->latestWalEnd;
+ latest_end_location = WalRcv->latestWalEnd;
latest_end_time = WalRcv->latestWalEndTime;
strlcpy(slotname, (char *) WalRcv->slotname, sizeof(slotname));
strlcpy(sender_host, (char *) WalRcv->sender_host, sizeof(sender_host));
@@ -1390,10 +1390,10 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
nulls[8] = true;
else
values[8] = TimestampTzGetDatum(last_receipt_time);
- if (XLogRecPtrIsInvalid(latest_end_lsn))
+ if (XLogRecPtrIsInvalid(latest_end_location))
nulls[9] = true;
else
- values[9] = LSNGetDatum(latest_end_lsn);
+ values[9] = LSNGetDatum(latest_end_location);
if (latest_end_time == 0)
nulls[10] = true;
else
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..eb60f2cfb8 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -60,7 +60,7 @@
#include "catalog/pg_rewrite.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_statistic_ext.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
@@ -115,7 +115,7 @@ static const FormData_pg_attribute Desc_pg_authid[Natts_pg_authid] = {Schema_pg_
static const FormData_pg_attribute Desc_pg_auth_members[Natts_pg_auth_members] = {Schema_pg_auth_members};
static const FormData_pg_attribute Desc_pg_index[Natts_pg_index] = {Schema_pg_index};
static const FormData_pg_attribute Desc_pg_shseclabel[Natts_pg_shseclabel] = {Schema_pg_shseclabel};
-static const FormData_pg_attribute Desc_pg_subscription[Natts_pg_subscription] = {Schema_pg_subscription};
+static const FormData_pg_attribute Desc_pg_sub[Natts_pg_sub] = {Schema_pg_sub};
/*
* Hash tables that index the relation cache
@@ -3845,8 +3845,8 @@ RelationCacheInitializePhase2(void)
Natts_pg_auth_members, Desc_pg_auth_members);
formrdesc("pg_shseclabel", SharedSecLabelRelation_Rowtype_Id, true,
Natts_pg_shseclabel, Desc_pg_shseclabel);
- formrdesc("pg_subscription", SubscriptionRelation_Rowtype_Id, true,
- Natts_pg_subscription, Desc_pg_subscription);
+ formrdesc("pg_sub", SubscriptionRelation_Rowtype_Id, true,
+ Natts_pg_sub, Desc_pg_sub);
#define NUM_CRITICAL_SHARED_RELS 5 /* fix if you change list above */
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index e4dc4ee34e..a012f77f9b 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -62,8 +62,8 @@
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
-#include "catalog/pg_subscription.h"
-#include "catalog/pg_subscription_rel.h"
+#include "catalog/pg_sub.h"
+#include "catalog/pg_sub_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
@@ -787,8 +787,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionNameIndexId,
2,
{
- Anum_pg_subscription_subdbid,
- Anum_pg_subscription_subname,
+ Anum_pg_sub_subdbid,
+ Anum_pg_sub_subname,
0,
0
},
@@ -798,7 +798,7 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionObjectIndexId,
1,
{
- Anum_pg_subscription_oid,
+ Anum_pg_sub_oid,
0,
0,
0
@@ -809,8 +809,8 @@ static const struct cachedesc cacheinfo[] = {
SubscriptionRelSrrelidSrsubidIndexId,
2,
{
- Anum_pg_subscription_rel_srrelid,
- Anum_pg_subscription_rel_srsubid,
+ Anum_pg_sub_rel_srrelid,
+ Anum_pg_sub_rel_srsubid,
0,
0
},
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index 60d306e7c3..00743ead8e 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -46,7 +46,7 @@ static void AddAcl(PQExpBuffer aclbuf, const char *keyword,
* remoteVersion: version of database
*
* Returns true if okay, false if could not parse the acl string.
- * The resulting commands (if any) are appended to the contents of 'sql'.
+ * The resulting commands (if any) are appended to the contents of 'sqltest'.
*
* Note: when processing a default ACL, prefix is "ALTER DEFAULT PRIVILEGES "
* or something similar, and name is an empty string.
@@ -378,7 +378,7 @@ buildACLCommands(const char *name, const char *subname, const char *nspname,
* remoteVersion: version of database
*
* Returns true if okay, false if could not parse the acl string.
- * The resulting commands (if any) are appended to the contents of 'sql'.
+ * The resulting commands (if any) are appended to the contents of 'sqltest'.
*/
bool
buildDefaultACLCommands(const char *type, const char *nspname,
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index eb988d7eb4..e518a0af63 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -4244,7 +4244,7 @@ getSubscriptions(Archive *fout)
int n;
res = ExecuteSqlQuery(fout,
- "SELECT count(*) FROM pg_subscription "
+ "SELECT count(*) FROM pg_sub "
"WHERE subdbid = (SELECT oid FROM pg_database"
" WHERE datname = current_database())",
PGRES_TUPLES_OK);
@@ -4276,7 +4276,7 @@ getSubscriptions(Archive *fout)
appendPQExpBufferStr(query, " false AS substream\n");
appendPQExpBufferStr(query,
- "FROM pg_subscription s\n"
+ "FROM pg_sub s\n"
"WHERE s.subdbid = (SELECT oid FROM pg_database\n"
" WHERE datname = current_database())");
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 737e46464a..f1f35a77ef 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -1867,10 +1867,10 @@ my %tests = (
'CREATE FUNCTION ... SUPPORT' => {
create_order => 41,
create_sql =>
- 'CREATE FUNCTION dump_test.func_with_support() RETURNS int LANGUAGE sql AS $$ SELECT 1 $$ SUPPORT varchar_support;',
+ 'CREATE FUNCTION dump_test.func_with_support() RETURNS int LANGUAGE sqltest AS $$ SELECT 1 $$ SUPPORT varchar_support;',
regexp => qr/^
\QCREATE FUNCTION dump_test.func_with_support() RETURNS integer\E
- \n\s+\QLANGUAGE sql SUPPORT varchar_support\E
+ \n\s+\QLANGUAGE sqltest SUPPORT varchar_support\E
\n\s+AS\ \$\$\Q SELECT 1 \E\$\$;
/xm,
like =>
@@ -1881,10 +1881,10 @@ my %tests = (
'CREATE PROCEDURE dump_test.ptest1' => {
create_order => 41,
create_sql => 'CREATE PROCEDURE dump_test.ptest1(a int)
- LANGUAGE SQL AS $$ INSERT INTO dump_test.test_table (col1) VALUES (a) $$;',
+ LANGUAGE SQLTEST AS $$ INSERT INTO dump_test.test_table (col1) VALUES (a) $$;',
regexp => qr/^
\QCREATE PROCEDURE dump_test.ptest1(a integer)\E
- \n\s+\QLANGUAGE sql\E
+ \n\s+\QLANGUAGE sqltest\E
\n\s+AS\ \$\$\Q INSERT INTO dump_test.test_table (col1) VALUES (a) \E\$\$;
/xm,
like =>
@@ -1987,9 +1987,9 @@ my %tests = (
'CREATE TRANSFORM FOR int' => {
create_order => 34,
create_sql =>
- 'CREATE TRANSFORM FOR int LANGUAGE SQL (FROM SQL WITH FUNCTION prsd_lextype(internal), TO SQL WITH FUNCTION int4recv(internal));',
+ 'CREATE TRANSFORM FOR int LANGUAGE SQLTEST (FROM SQL WITH FUNCTION prsd_lextype(internal), TO SQL WITH FUNCTION int4recv(internal));',
regexp =>
- qr/CREATE TRANSFORM FOR integer LANGUAGE sql \(FROM SQL WITH FUNCTION pg_catalog\.prsd_lextype\(internal\), TO SQL WITH FUNCTION pg_catalog\.int4recv\(internal\)\);/m,
+ qr/CREATE TRANSFORM FOR integer LANGUAGE sqltest \(FROM SQL WITH FUNCTION pg_catalog\.prsd_lextype\(internal\), TO SQL WITH FUNCTION pg_catalog\.int4recv\(internal\)\);/m,
like => { %full_runs, section_pre_data => 1, },
},
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 20af5a92b4..13c415c226 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -6088,7 +6088,7 @@ describeSubscriptions(const char *pattern, bool verbose)
printfPQExpBuffer(&buf,
"SELECT subname AS \"%s\"\n"
", pg_catalog.pg_get_userbyid(subowner) AS \"%s\"\n"
- ", subenabled AS \"%s\"\n"
+ ", subactive AS \"%s\"\n"
", subpublications AS \"%s\"\n",
gettext_noop("Name"),
gettext_noop("Owner"),
@@ -6114,7 +6114,7 @@ describeSubscriptions(const char *pattern, bool verbose)
/* Only display subscriptions in current database. */
appendPQExpBufferStr(&buf,
- "FROM pg_catalog.pg_subscription\n"
+ "FROM pg_catalog.pg_sub\n"
"WHERE subdbid = (SELECT oid\n"
" FROM pg_catalog.pg_database\n"
" WHERE datname = pg_catalog.current_database())");
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 1e1c315bae..0cd63ae201 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -999,7 +999,7 @@ static const VersionedQuery Query_for_list_of_publications[] = {
static const VersionedQuery Query_for_list_of_subscriptions[] = {
{100000,
" SELECT pg_catalog.quote_ident(s.subname) "
- " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d "
+ " FROM pg_catalog.pg_sub s, pg_catalog.pg_database d "
" WHERE substring(pg_catalog.quote_ident(s.subname),1,%d)='%s' "
" AND d.datname = pg_catalog.current_database() "
" AND s.subdbid = d.oid"
diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl
index 99ec8bebde..8599f8eaa7 100644
--- a/src/bin/scripts/t/100_vacuumdb.pl
+++ b/src/bin/scripts/t/100_vacuumdb.pl
@@ -95,8 +95,8 @@ $node->safe_psql(
CREATE TABLE vactable (a int, b int);
CREATE VIEW vacview AS SELECT 1 as a;
- CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQL AS 'SELECT $1 * $1';
- CREATE FUNCTION f1(int) RETURNS int LANGUAGE SQL AS 'SELECT f0($1)';
+ CREATE FUNCTION f0(int) RETURNS int LANGUAGE SQLTEST AS 'SELECT $1 * $1';
+ CREATE FUNCTION f1(int) RETURNS int LANGUAGE SQLTEST AS 'SELECT f0($1)';
CREATE TABLE funcidx (x int);
INSERT INTO funcidx VALUES (0),(1),(2),(3);
CREATE INDEX i0 ON funcidx ((f1(x)));
diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h
index f272e2c99f..06c6128183 100644
--- a/src/include/catalog/dependency.h
+++ b/src/include/catalog/dependency.h
@@ -131,7 +131,7 @@ typedef enum ObjectClass
OCLASS_POLICY, /* pg_policy */
OCLASS_PUBLICATION, /* pg_publication */
OCLASS_PUBLICATION_REL, /* pg_publication_rel */
- OCLASS_SUBSCRIPTION, /* pg_subscription */
+ OCLASS_SUBSCRIPTION, /* pg_sub */
OCLASS_TRANSFORM /* pg_transform */
} ObjectClass;
diff --git a/src/include/catalog/pg_language.dat b/src/include/catalog/pg_language.dat
index a584679927..88f710f9f0 100644
--- a/src/include/catalog/pg_language.dat
+++ b/src/include/catalog/pg_language.dat
@@ -20,6 +20,6 @@
lanname => 'c', lanvalidator => 'fmgr_c_validator' },
{ oid => '14', oid_symbol => 'SQLlanguageId',
descr => 'SQL-language functions',
- lanname => 'sql', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
+ lanname => 'sqltest', lanpltrusted => 't', lanvalidator => 'fmgr_sql_validator' },
]
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 4e0c9be58c..0a5a515d6b 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -2350,7 +2350,7 @@
proname => 'justify_days', prorettype => 'interval',
proargtypes => 'interval', prosrc => 'interval_justify_days' },
{ oid => '1176', descr => 'convert date and time to timestamp with time zone',
- proname => 'timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'timestamptz', prolang => 'sqltest', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'date time',
prosrc => 'select cast(($1 + $2) as timestamp with time zone)' },
{ oid => '1178', descr => 'convert timestamp with time zone to date',
@@ -2403,16 +2403,16 @@
prosrc => 'interval_scale' },
{ oid => '1215', descr => 'get description for object id and catalog name',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = \'pg_catalog\'::pg_catalog.regnamespace) and objsubid = 0' },
{ oid => '1216', descr => 'get description for table column',
- proname => 'col_description', prolang => 'sql', procost => '100',
+ proname => 'col_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid int4',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and classoid = \'pg_catalog.pg_class\'::pg_catalog.regclass and objsubid = $2' },
{ oid => '1993',
descr => 'get description for object id and shared catalog name',
- proname => 'shobj_description', prolang => 'sql', procost => '100',
+ proname => 'shobj_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid name',
prosrc => 'select description from pg_catalog.pg_shdescription where objoid = $1 and classoid = (select oid from pg_catalog.pg_class where relname = $2 and relnamespace = \'pg_catalog\'::pg_catalog.regnamespace)' },
@@ -2585,13 +2585,13 @@
prosrc => 'hashtidextended' },
{ oid => '1296',
- proname => 'timedate_pl', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'timedate_pl', prolang => 'sqltest', prorettype => 'timestamp',
proargtypes => 'time date', prosrc => 'select ($2 + $1)' },
{ oid => '1297',
proname => 'datetimetz_pl', prorettype => 'timestamptz',
proargtypes => 'date timetz', prosrc => 'datetimetz_timestamptz' },
{ oid => '1298',
- proname => 'timetzdate_pl', prolang => 'sql', prorettype => 'timestamptz',
+ proname => 'timetzdate_pl', prolang => 'sqltest', prorettype => 'timestamptz',
proargtypes => 'timetz date', prosrc => 'select ($2 + $1)' },
{ oid => '1299', descr => 'current transaction time',
proname => 'now', provolatile => 's', prorettype => 'timestamptz',
@@ -2633,17 +2633,17 @@
proargtypes => 'timestamptz timestamptz timestamptz timestamptz',
prosrc => 'overlaps_timestamp' },
{ oid => '1305', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1306', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz timestamptz timestamptz interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1307', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'bool',
proargtypes => 'timestamptz interval timestamptz timestamptz',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2652,15 +2652,15 @@
proname => 'overlaps', proisstrict => 'f', prorettype => 'bool',
proargtypes => 'time time time time', prosrc => 'overlaps_time' },
{ oid => '1309', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '1310', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time time time interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '1311', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'time interval time time',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
@@ -2741,7 +2741,7 @@
# This form of obj_description is now deprecated, since it will fail if
# OIDs are not unique across system catalogs. Use the other form instead.
{ oid => '1348', descr => 'deprecated, use two-argument form instead',
- proname => 'obj_description', prolang => 'sql', procost => '100',
+ proname => 'obj_description', prolang => 'sqltest', procost => '100',
provolatile => 's', prorettype => 'text', proargtypes => 'oid',
prosrc => 'select description from pg_catalog.pg_description where objoid = $1 and objsubid = 0' },
@@ -2825,7 +2825,7 @@
prosrc => 'textlen' },
{ oid => '1384', descr => 'extract field from date',
- proname => 'date_part', prolang => 'sql', prorettype => 'float8',
+ proname => 'date_part', prolang => 'sqltest', prorettype => 'float8',
proargtypes => 'text date',
prosrc => 'select pg_catalog.date_part($1, cast($2 as timestamp without time zone))' },
{ oid => '1385', descr => 'extract field from time',
@@ -2833,7 +2833,7 @@
prosrc => 'time_part' },
{ oid => '1386',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'sqltest', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp with time zone), $1)' },
@@ -2948,7 +2948,7 @@
proname => 'box_div', prorettype => 'box', proargtypes => 'box point',
prosrc => 'box_div' },
{ oid => '1426',
- proname => 'path_contain_pt', prolang => 'sql', prorettype => 'bool',
+ proname => 'path_contain_pt', prolang => 'sqltest', prorettype => 'bool',
proargtypes => 'path point', prosrc => 'select pg_catalog.on_ppath($2, $1)' },
{ oid => '1428',
proname => 'poly_contain_pt', prorettype => 'bool',
@@ -3208,7 +3208,7 @@
proname => 'center', prorettype => 'point', proargtypes => 'circle',
prosrc => 'circle_center' },
{ oid => '1544', descr => 'convert circle to 12-vertex polygon',
- proname => 'polygon', prolang => 'sql', prorettype => 'polygon',
+ proname => 'polygon', prolang => 'sqltest', prorettype => 'polygon',
proargtypes => 'circle', prosrc => 'select pg_catalog.polygon(12, $1)' },
{ oid => '1545', descr => 'number of points',
proname => 'npoints', prorettype => 'int4', proargtypes => 'path',
@@ -3504,11 +3504,11 @@
proname => 'translate', prorettype => 'text', proargtypes => 'text text text',
prosrc => 'translate' },
{ oid => '879', descr => 'left-pad string to length',
- proname => 'lpad', prolang => 'sql', prorettype => 'text',
+ proname => 'lpad', prolang => 'sqltest', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.lpad($1, $2, \' \')' },
{ oid => '880', descr => 'right-pad string to length',
- proname => 'rpad', prolang => 'sql', prorettype => 'text',
+ proname => 'rpad', prolang => 'sqltest', prorettype => 'text',
proargtypes => 'text int4',
prosrc => 'select pg_catalog.rpad($1, $2, \' \')' },
{ oid => '881', descr => 'trim spaces from left end of string',
@@ -4110,7 +4110,7 @@
proname => 'inetpl', prorettype => 'inet', proargtypes => 'inet int8',
prosrc => 'inetpl' },
{ oid => '2631',
- proname => 'int8pl_inet', prolang => 'sql', prorettype => 'inet',
+ proname => 'int8pl_inet', prolang => 'sqltest', prorettype => 'inet',
proargtypes => 'int8 inet', prosrc => 'select $2 + $1' },
{ oid => '2632',
proname => 'inetmi_int8', prorettype => 'inet', proargtypes => 'inet int8',
@@ -4242,13 +4242,13 @@
proname => 'round', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_round' },
{ oid => '1708', descr => 'value rounded to \'scale\' of zero',
- proname => 'round', prolang => 'sql', prorettype => 'numeric',
+ proname => 'round', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.round($1,0)' },
{ oid => '1709', descr => 'value truncated to \'scale\'',
proname => 'trunc', prorettype => 'numeric', proargtypes => 'numeric int4',
prosrc => 'numeric_trunc' },
{ oid => '1710', descr => 'value truncated to \'scale\' of zero',
- proname => 'trunc', prolang => 'sql', prorettype => 'numeric',
+ proname => 'trunc', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.trunc($1,0)' },
{ oid => '1711', descr => 'nearest integer >= value',
proname => 'ceil', prorettype => 'numeric', proargtypes => 'numeric',
@@ -4348,10 +4348,10 @@
proname => 'numeric', proleakproof => 't', prorettype => 'numeric',
proargtypes => 'int4', prosrc => 'int4_numeric' },
{ oid => '1741', descr => 'base 10 logarithm',
- proname => 'log', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1481', descr => 'base 10 logarithm',
- proname => 'log10', prolang => 'sql', prorettype => 'numeric',
+ proname => 'log10', prolang => 'sqltest', prorettype => 'numeric',
proargtypes => 'numeric', prosrc => 'select pg_catalog.log(10, $1)' },
{ oid => '1742', descr => 'convert float4 to numeric',
proname => 'numeric', proleakproof => 't', prorettype => 'numeric',
@@ -4487,7 +4487,7 @@
proname => 'quote_literal', prorettype => 'text', proargtypes => 'text',
prosrc => 'quote_literal' },
{ oid => '1285', descr => 'quote a data value for usage in a querystring',
- proname => 'quote_literal', prolang => 'sql', provolatile => 's',
+ proname => 'quote_literal', prolang => 'sqltest', provolatile => 's',
prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_literal($1::pg_catalog.text)' },
{ oid => '1289',
@@ -4496,7 +4496,7 @@
proargtypes => 'text', prosrc => 'quote_nullable' },
{ oid => '1290',
descr => 'quote a possibly-null data value for usage in a querystring',
- proname => 'quote_nullable', prolang => 'sql', proisstrict => 'f',
+ proname => 'quote_nullable', prolang => 'sqltest', proisstrict => 'f',
provolatile => 's', prorettype => 'text', proargtypes => 'anyelement',
prosrc => 'select pg_catalog.quote_nullable($1::pg_catalog.text)' },
@@ -4535,13 +4535,13 @@
prorettype => 'text', proargtypes => 'text', prosrc => 'text_format_nv' },
{ oid => '1810', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'sqltest', prorettype => 'int4',
proargtypes => 'bytea', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1811', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'sqltest', prorettype => 'int4',
proargtypes => 'text', prosrc => 'select pg_catalog.octet_length($1) * 8' },
{ oid => '1812', descr => 'length in bits',
- proname => 'bit_length', prolang => 'sql', prorettype => 'int4',
+ proname => 'bit_length', prolang => 'sqltest', prorettype => 'int4',
proargtypes => 'bit', prosrc => 'select pg_catalog.length($1)' },
# Selectivity estimators for LIKE and related operators
@@ -4860,7 +4860,7 @@
prosrc => 'to_ascii_encname' },
{ oid => '1848',
- proname => 'interval_pl_time', prolang => 'sql', prorettype => 'time',
+ proname => 'interval_pl_time', prolang => 'sqltest', prorettype => 'time',
proargtypes => 'interval time', prosrc => 'select $2 + $1' },
{ oid => '1850',
@@ -5273,7 +5273,7 @@
proparallel => 'r', prorettype => 'record', proargtypes => '',
proallargtypes => '{int4,text,pg_lsn,int4,pg_lsn,pg_lsn,int4,timestamptz,timestamptz,pg_lsn,timestamptz,text,text,int4,text}',
proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
- proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
+ proargnames => '{pid,status,receive_start_lsn,receive_start_tli,written_lsn,flushed_lsn,received_tli,last_msg_send_time,last_msg_receipt_time,latest_end_location,latest_end_time,slot_name,sender_host,sender_port,conninfo}',
prosrc => 'pg_stat_get_wal_receiver' },
{ oid => '8595', descr => 'statistics: information about replication slots',
proname => 'pg_stat_get_replication_slots', prorows => '10',
@@ -5284,12 +5284,12 @@
proargnames => '{slot_name,spill_txns,spill_count,spill_bytes,stream_txns,stream_count,stream_bytes,stats_reset}',
prosrc => 'pg_stat_get_replication_slots' },
{ oid => '6118', descr => 'statistics: information about subscription',
- proname => 'pg_stat_get_subscription', proisstrict => 'f', provolatile => 's',
+ proname => 'pg_stat_get_sub', proisstrict => 'f', provolatile => 's',
proparallel => 'r', prorettype => 'record', proargtypes => 'oid',
proallargtypes => '{oid,oid,oid,int4,pg_lsn,timestamptz,timestamptz,pg_lsn,timestamptz}',
proargmodes => '{i,o,o,o,o,o,o,o,o}',
- proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_lsn,latest_end_time}',
- prosrc => 'pg_stat_get_subscription' },
+ proargnames => '{subid,subid,relid,pid,received_lsn,last_msg_send_time,last_msg_receipt_time,latest_end_location,latest_end_time}',
+ prosrc => 'pg_stat_get_sub' },
{ oid => '2026', descr => 'statistics: current backend PID',
proname => 'pg_backend_pid', provolatile => 's', proparallel => 'r',
prorettype => 'int4', proargtypes => '', prosrc => 'pg_backend_pid' },
@@ -5743,11 +5743,11 @@
proargtypes => 'timetz int4', prosrc => 'timetz_scale' },
{ oid => '2003',
- proname => 'textanycat', prolang => 'sql', provolatile => 's',
+ proname => 'textanycat', prolang => 'sqltest', provolatile => 's',
prorettype => 'text', proargtypes => 'text anynonarray',
prosrc => 'select $1 || $2::pg_catalog.text' },
{ oid => '2004',
- proname => 'anytextcat', prolang => 'sql', provolatile => 's',
+ proname => 'anytextcat', prolang => 'sqltest', provolatile => 's',
prorettype => 'text', proargtypes => 'anynonarray text',
prosrc => 'select $1::pg_catalog.text || $2' },
@@ -5853,15 +5853,15 @@
proargtypes => 'timestamp timestamp timestamp timestamp',
prosrc => 'overlaps_timestamp' },
{ oid => '2042', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp interval',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, ($3 + $4))' },
{ oid => '2043', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp timestamp timestamp interval',
prosrc => 'select ($1, $2) overlaps ($3, ($3 + $4))' },
{ oid => '2044', descr => 'intervals overlap?',
- proname => 'overlaps', prolang => 'sql', proisstrict => 'f',
+ proname => 'overlaps', prolang => 'sqltest', proisstrict => 'f',
prorettype => 'bool', proargtypes => 'timestamp interval timestamp timestamp',
prosrc => 'select ($1, ($1 + $2)) overlaps ($3, $4)' },
{ oid => '2045', descr => 'less-equal-greater',
@@ -5927,7 +5927,7 @@
proargtypes => 'timestamp timestamp', prosrc => 'timestamp_age' },
{ oid => '2059',
descr => 'date difference from today preserving months and years',
- proname => 'age', prolang => 'sql', provolatile => 's',
+ proname => 'age', prolang => 'sqltest', provolatile => 's',
prorettype => 'interval', proargtypes => 'timestamp',
prosrc => 'select pg_catalog.age(cast(current_date as timestamp without time zone), $1)' },
@@ -5948,7 +5948,7 @@
proname => 'substring', prorettype => 'text', proargtypes => 'text text',
prosrc => 'textregexsubstr' },
{ oid => '2074', descr => 'extract text matching SQL regular expression',
- proname => 'substring', prolang => 'sql', prorettype => 'text',
+ proname => 'substring', prolang => 'sqltest', prorettype => 'text',
proargtypes => 'text text text',
prosrc => 'select pg_catalog.substring($1, pg_catalog.similar_to_escape($2, $3))' },
@@ -6296,11 +6296,11 @@
proname => 'pg_sleep', provolatile => 'v', prorettype => 'void',
proargtypes => 'float8', prosrc => 'pg_sleep' },
{ oid => '3935', descr => 'sleep for the specified interval',
- proname => 'pg_sleep_for', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_for', prolang => 'sqltest', provolatile => 'v',
prorettype => 'void', proargtypes => 'interval',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from pg_catalog.clock_timestamp() operator(pg_catalog.+) $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '3936', descr => 'sleep until the specified time',
- proname => 'pg_sleep_until', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_sleep_until', prolang => 'sqltest', provolatile => 'v',
prorettype => 'void', proargtypes => 'timestamptz',
prosrc => 'select pg_catalog.pg_sleep(extract(epoch from $1) operator(pg_catalog.-) extract(epoch from pg_catalog.clock_timestamp()))' },
{ oid => '315', descr => 'Is JIT compilation available in this session?',
@@ -7111,7 +7111,7 @@
proargtypes => 'name', prosrc => 'pg_database_size_name' },
{ oid => '2325',
descr => 'disk space usage for the main fork of the specified table or index',
- proname => 'pg_relation_size', prolang => 'sql', provolatile => 'v',
+ proname => 'pg_relation_size', prolang => 'sqltest', provolatile => 'v',
prorettype => 'int8', proargtypes => 'regclass',
prosrc => 'select pg_catalog.pg_relation_size($1, \'main\')' },
{ oid => '2332',
@@ -8013,21 +8013,21 @@
# formerly-missing interval + datetime operators
{ oid => '2546',
- proname => 'interval_pl_date', prolang => 'sql', prorettype => 'timestamp',
+ proname => 'interval_pl_date', prolang => 'sqltest', prorettype => 'timestamp',
proargtypes => 'interval date', prosrc => 'select $2 + $1' },
{ oid => '2547',
- proname => 'interval_pl_timetz', prolang => 'sql', prorettype => 'timetz',
+ proname => 'interval_pl_timetz', prolang => 'sqltest', prorettype => 'timetz',
proargtypes => 'interval timetz', prosrc => 'select $2 + $1' },
{ oid => '2548',
- proname => 'interval_pl_timestamp', prolang => 'sql',
+ proname => 'interval_pl_timestamp', prolang => 'sqltest',
prorettype => 'timestamp', proargtypes => 'interval timestamp',
prosrc => 'select $2 + $1' },
{ oid => '2549',
- proname => 'interval_pl_timestamptz', prolang => 'sql', provolatile => 's',
+ proname => 'interval_pl_timestamptz', prolang => 'sqltest', provolatile => 's',
prorettype => 'timestamptz', proargtypes => 'interval timestamptz',
prosrc => 'select $2 + $1' },
{ oid => '2550',
- proname => 'integer_pl_date', prolang => 'sql', prorettype => 'date',
+ proname => 'integer_pl_date', prolang => 'sqltest', prorettype => 'date',
proargtypes => 'int4 date', prosrc => 'select $2 + $1' },
{ oid => '2556', descr => 'get OIDs of databases in a tablespace',
@@ -8419,7 +8419,7 @@
proname => 'xpath', prorettype => '_xml', proargtypes => 'text xml _text',
prosrc => 'xpath' },
{ oid => '2932', descr => 'evaluate XPath expression',
- proname => 'xpath', prolang => 'sql', prorettype => '_xml',
+ proname => 'xpath', prolang => 'sqltest', prorettype => '_xml',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath($1, $2, \'{}\'::pg_catalog.text[])' },
@@ -8432,7 +8432,7 @@
proname => 'xpath_exists', prorettype => 'bool',
proargtypes => 'text xml _text', prosrc => 'xpath_exists' },
{ oid => '3050', descr => 'test XML value against XPath expression',
- proname => 'xpath_exists', prolang => 'sql', prorettype => 'bool',
+ proname => 'xpath_exists', prolang => 'sqltest', prorettype => 'bool',
proargtypes => 'text xml',
prosrc => 'select pg_catalog.xpath_exists($1, $2, \'{}\'::pg_catalog.text[])' },
{ oid => '3051', descr => 'determine if a string is well formed XML',
@@ -8698,7 +8698,7 @@
proname => 'pg_lsn_pli', prorettype => 'pg_lsn',
proargtypes => 'pg_lsn numeric', prosrc => 'pg_lsn_pli' },
{ oid => '5023',
- proname => 'numeric_pl_pg_lsn', prolang => 'sql', prorettype => 'pg_lsn',
+ proname => 'numeric_pl_pg_lsn', prolang => 'sqltest', prorettype => 'pg_lsn',
proargtypes => 'numeric pg_lsn', prosrc => 'select $2 + $1' },
{ oid => '5024',
proname => 'pg_lsn_mii', prorettype => 'pg_lsn',
diff --git a/src/include/catalog/pg_subscription.h b/src/include/catalog/pg_sub.h
similarity index 78%
rename from src/include/catalog/pg_subscription.h
rename to src/include/catalog/pg_sub.h
index a5d6efdf20..2c03807159 100644
--- a/src/include/catalog/pg_subscription.h
+++ b/src/include/catalog/pg_sub.h
@@ -1,12 +1,12 @@
/* -------------------------------------------------------------------------
*
- * pg_subscription.h
- * definition of the "subscription" system catalog (pg_subscription)
+ * pg_sub.h
+ * definition of the "subscription" system catalog (pg_sub)
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * src/include/catalog/pg_subscription.h
+ * src/include/catalog/pg_sub.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
@@ -18,13 +18,13 @@
#define PG_SUBSCRIPTION_H
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_d.h"
+#include "catalog/pg_sub_d.h"
#include "nodes/pg_list.h"
/* ----------------
- * pg_subscription definition. cpp turns this into
- * typedef struct FormData_pg_subscription
+ * pg_sub definition. cpp turns this into
+ * typedef struct FormData_pg_sub
* ----------------
*/
@@ -36,7 +36,7 @@
*
* NOTE: When adding a column, also update system_views.sql.
*/
-CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
+CATALOG(pg_sub,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(6101,SubscriptionRelation_Rowtype_Id) BKI_SCHEMA_MACRO
{
Oid oid; /* oid */
@@ -46,7 +46,7 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
Oid subowner BKI_LOOKUP(pg_authid); /* Owner of the subscription */
- bool subenabled; /* True if the subscription is enabled (the
+ bool subactive; /* True if the subscription is enabled (the
* worker should be running) */
bool subbinary; /* True if the subscription wants the
@@ -67,17 +67,17 @@ CATALOG(pg_subscription,6100,SubscriptionRelationId) BKI_SHARED_RELATION BKI_ROW
/* List of publications subscribed to */
text subpublications[1] BKI_FORCE_NOT_NULL;
#endif
-} FormData_pg_subscription;
+} FormData_pg_sub;
-typedef FormData_pg_subscription *Form_pg_subscription;
+typedef FormData_pg_sub *Form_pg_sub;
-DECLARE_TOAST(pg_subscription, 4183, 4184);
+DECLARE_TOAST(pg_sub, 4183, 4184);
#define PgSubscriptionToastTable 4183
#define PgSubscriptionToastIndex 4184
-DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_oid_index, 6114, on pg_subscription using btree(oid oid_ops));
+DECLARE_UNIQUE_INDEX_PKEY(pg_sub_oid_index, 6114, on pg_sub using btree(oid oid_ops));
#define SubscriptionObjectIndexId 6114
-DECLARE_UNIQUE_INDEX(pg_subscription_subname_index, 6115, on pg_subscription using btree(subdbid oid_ops, subname name_ops));
+DECLARE_UNIQUE_INDEX(pg_sub_subname_index, 6115, on pg_sub using btree(subdbid oid_ops, subname name_ops));
#define SubscriptionNameIndexId 6115
typedef struct Subscription
diff --git a/src/include/catalog/pg_subscription_rel.h b/src/include/catalog/pg_sub_rel.h
similarity index 79%
rename from src/include/catalog/pg_subscription_rel.h
rename to src/include/catalog/pg_sub_rel.h
index 2bea2c52aa..f15227c441 100644
--- a/src/include/catalog/pg_subscription_rel.h
+++ b/src/include/catalog/pg_sub_rel.h
@@ -1,13 +1,13 @@
/* -------------------------------------------------------------------------
*
- * pg_subscription_rel.h
+ * pg_sub_rel.h
* definition of the system catalog containing the state for each
- * replicated table in each subscription (pg_subscription_rel)
+ * replicated table in each subscription (pg_sub_rel)
*
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * src/include/catalog/pg_subscription_rel.h
+ * src/include/catalog/pg_sub_rel.h
*
* NOTES
* The Catalog.pm module reads this file and derives schema
@@ -20,17 +20,17 @@
#include "access/xlogdefs.h"
#include "catalog/genbki.h"
-#include "catalog/pg_subscription_rel_d.h"
+#include "catalog/pg_sub_rel_d.h"
#include "nodes/pg_list.h"
/* ----------------
- * pg_subscription_rel definition. cpp turns this into
- * typedef struct FormData_pg_subscription_rel
+ * pg_sub_rel definition. cpp turns this into
+ * typedef struct FormData_pg_sub_rel
* ----------------
*/
-CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
+CATALOG(pg_sub_rel,6102,SubscriptionRelRelationId)
{
- Oid srsubid BKI_LOOKUP(pg_subscription); /* Oid of subscription */
+ Oid srsubid BKI_LOOKUP(pg_sub); /* Oid of subscription */
Oid srrelid BKI_LOOKUP(pg_class); /* Oid of relation */
char srsubstate; /* state of the relation in subscription */
@@ -45,11 +45,11 @@ CATALOG(pg_subscription_rel,6102,SubscriptionRelRelationId)
* coordination, or NULL if not
* valid */
#endif
-} FormData_pg_subscription_rel;
+} FormData_pg_sub_rel;
-typedef FormData_pg_subscription_rel *Form_pg_subscription_rel;
+typedef FormData_pg_sub_rel *Form_pg_sub_rel;
-DECLARE_UNIQUE_INDEX_PKEY(pg_subscription_rel_srrelid_srsubid_index, 6117, on pg_subscription_rel using btree(srrelid oid_ops, srsubid oid_ops));
+DECLARE_UNIQUE_INDEX_PKEY(pg_sub_rel_srrelid_srsubid_index, 6117, on pg_sub_rel using btree(srrelid oid_ops, srsubid oid_ops));
#define SubscriptionRelSrrelidSrsubidIndexId 6117
#ifdef EXPOSE_TO_CLIENT_CODE
diff --git a/src/include/replication/worker_internal.h b/src/include/replication/worker_internal.h
index d046022e49..c7aeffb0b2 100644
--- a/src/include/replication/worker_internal.h
+++ b/src/include/replication/worker_internal.h
@@ -15,7 +15,7 @@
#include <signal.h>
#include "access/xlogdefs.h"
-#include "catalog/pg_subscription.h"
+#include "catalog/pg_sub.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
#include "storage/spin.h"
diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h
index 541a438387..ae07279501 100644
--- a/src/include/utils/acl.h
+++ b/src/include/utils/acl.h
@@ -303,7 +303,7 @@ extern bool pg_foreign_server_ownercheck(Oid srv_oid, Oid roleid);
extern bool pg_event_trigger_ownercheck(Oid et_oid, Oid roleid);
extern bool pg_extension_ownercheck(Oid ext_oid, Oid roleid);
extern bool pg_publication_ownercheck(Oid pub_oid, Oid roleid);
-extern bool pg_subscription_ownercheck(Oid sub_oid, Oid roleid);
+extern bool pg_sub_ownercheck(Oid sub_oid, Oid roleid);
extern bool pg_statistics_object_ownercheck(Oid stat_oid, Oid roleid);
extern bool has_createrole_privilege(Oid roleid);
extern bool has_bypassrls_privilege(Oid roleid);
diff --git a/src/pl/plperl/expected/plperl_trigger.out b/src/pl/plperl/expected/plperl_trigger.out
index d4879e2f03..c370a232d3 100644
--- a/src/pl/plperl/expected/plperl_trigger.out
+++ b/src/pl/plperl/expected/plperl_trigger.out
@@ -355,7 +355,7 @@ create event trigger perl_a_snitch on ddl_command_start
execute procedure perlsnitch();
create event trigger perl_b_snitch on ddl_command_end
execute procedure perlsnitch();
-create or replace function foobar() returns int language sql as $$select 1;$$;
+create or replace function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
NOTICE: perlsnitch: ddl_command_start CREATE FUNCTION
NOTICE: perlsnitch: ddl_command_end CREATE FUNCTION
alter function foobar() cost 77;
diff --git a/src/pl/plperl/sql/plperl_trigger.sql b/src/pl/plperl/sql/plperl_trigger.sql
index 4adddeb80a..c893fe772a 100644
--- a/src/pl/plperl/sql/plperl_trigger.sql
+++ b/src/pl/plperl/sql/plperl_trigger.sql
@@ -232,7 +232,7 @@ create event trigger perl_a_snitch on ddl_command_start
create event trigger perl_b_snitch on ddl_command_end
execute procedure perlsnitch();
-create or replace function foobar() returns int language sql as $$select 1;$$;
+create or replace function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
alter function foobar() cost 77;
drop function foobar();
diff --git a/src/pl/plpgsql/src/expected/plpgsql_simple.out b/src/pl/plpgsql/src/expected/plpgsql_simple.out
index 5a2fefa03e..8fa8893b01 100644
--- a/src/pl/plpgsql/src/expected/plpgsql_simple.out
+++ b/src/pl/plpgsql/src/expected/plpgsql_simple.out
@@ -2,7 +2,7 @@
-- Tests for plpgsql's handling of "simple" expressions
--
-- Check that changes to an inline-able function are handled correctly
-create function simplesql(int) returns int language sql
+create function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1';
create function simplecaller() returns int language plpgsql
as $$
@@ -12,7 +12,7 @@ begin
for n in 1..10 loop
sum := sum + simplesql(n);
if n = 5 then
- create or replace function simplesql(int) returns int language sql
+ create or replace function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1 + 100';
end if;
end loop;
diff --git a/src/pl/plpgsql/src/expected/plpgsql_transaction.out b/src/pl/plpgsql/src/expected/plpgsql_transaction.out
index 5f576231c3..6bba3839f1 100644
--- a/src/pl/plpgsql/src/expected/plpgsql_transaction.out
+++ b/src/pl/plpgsql/src/expected/plpgsql_transaction.out
@@ -491,7 +491,7 @@ CONTEXT: PL/pgSQL function inline_code_block line 3 at EXECUTE
-- snapshot handling test
TRUNCATE test2;
CREATE PROCEDURE transaction_test9()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO test2 VALUES (42);
$$;
diff --git a/src/pl/plpgsql/src/sql/plpgsql_simple.sql b/src/pl/plpgsql/src/sql/plpgsql_simple.sql
index 8a95768073..9dc14b425b 100644
--- a/src/pl/plpgsql/src/sql/plpgsql_simple.sql
+++ b/src/pl/plpgsql/src/sql/plpgsql_simple.sql
@@ -3,7 +3,7 @@
--
-- Check that changes to an inline-able function are handled correctly
-create function simplesql(int) returns int language sql
+create function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1';
create function simplecaller() returns int language plpgsql
@@ -14,7 +14,7 @@ begin
for n in 1..10 loop
sum := sum + simplesql(n);
if n = 5 then
- create or replace function simplesql(int) returns int language sql
+ create or replace function simplesql(int) returns int LANGUAGE SQLTEST
as 'select $1 + 100';
end if;
end loop;
diff --git a/src/pl/plpgsql/src/sql/plpgsql_transaction.sql b/src/pl/plpgsql/src/sql/plpgsql_transaction.sql
index 7575655c1a..07a9c7b9d7 100644
--- a/src/pl/plpgsql/src/sql/plpgsql_transaction.sql
+++ b/src/pl/plpgsql/src/sql/plpgsql_transaction.sql
@@ -410,7 +410,7 @@ $$;
TRUNCATE test2;
CREATE PROCEDURE transaction_test9()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO test2 VALUES (42);
$$;
diff --git a/src/pl/tcl/expected/pltcl_setup.out b/src/pl/tcl/expected/pltcl_setup.out
index ed809f02bf..6452cde8b4 100644
--- a/src/pl/tcl/expected/pltcl_setup.out
+++ b/src/pl/tcl/expected/pltcl_setup.out
@@ -139,7 +139,7 @@ create function tclsnitch() returns event_trigger language pltcl as $$
$$;
create event trigger tcl_a_snitch on ddl_command_start execute procedure tclsnitch();
create event trigger tcl_b_snitch on ddl_command_end execute procedure tclsnitch();
-create function foobar() returns int language sql as $$select 1;$$;
+create function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
NOTICE: tclsnitch: ddl_command_start CREATE FUNCTION
NOTICE: tclsnitch: ddl_command_end CREATE FUNCTION
alter function foobar() cost 77;
diff --git a/src/pl/tcl/sql/pltcl_setup.sql b/src/pl/tcl/sql/pltcl_setup.sql
index e9f59989b5..8296e4f6f7 100644
--- a/src/pl/tcl/sql/pltcl_setup.sql
+++ b/src/pl/tcl/sql/pltcl_setup.sql
@@ -156,7 +156,7 @@ $$;
create event trigger tcl_a_snitch on ddl_command_start execute procedure tclsnitch();
create event trigger tcl_b_snitch on ddl_command_end execute procedure tclsnitch();
-create function foobar() returns int language sql as $$select 1;$$;
+create function foobar() returns int LANGUAGE SQLTEST as $$select 1;$$;
alter function foobar() cost 77;
drop function foobar();
diff --git a/src/test/isolation/specs/deadlock-parallel.spec b/src/test/isolation/specs/deadlock-parallel.spec
index 7ad290c0bd..5ae4082052 100644
--- a/src/test/isolation/specs/deadlock-parallel.spec
+++ b/src/test/isolation/specs/deadlock-parallel.spec
@@ -36,10 +36,10 @@
setup
{
- create function lock_share(int,int) returns int language sql as
+ create function lock_share(int,int) returns int LANGUAGE SQLTEST as
'select pg_advisory_xact_lock_shared($1); select 1;' parallel safe;
- create function lock_excl(int,int) returns int language sql as
+ create function lock_excl(int,int) returns int LANGUAGE SQLTEST as
'select pg_advisory_xact_lock($1); select 1;' parallel safe;
create table bigt as select x from generate_series(1, 10000) x;
diff --git a/src/test/isolation/specs/eval-plan-qual.spec b/src/test/isolation/specs/eval-plan-qual.spec
index 70fa320fc4..c5558284d3 100644
--- a/src/test/isolation/specs/eval-plan-qual.spec
+++ b/src/test/isolation/specs/eval-plan-qual.spec
@@ -9,7 +9,7 @@ setup
CREATE TABLE accounts (accountid text PRIMARY KEY, balance numeric not null);
INSERT INTO accounts VALUES ('checking', 600), ('savings', 600);
- CREATE FUNCTION update_checking(int) RETURNS bool LANGUAGE sql AS $$
+ CREATE FUNCTION update_checking(int) RETURNS bool LANGUAGE sqltest AS $$
UPDATE accounts SET balance = balance + 1 WHERE accountid = 'checking'; SELECT true;$$;
CREATE TABLE accounts_ext (accountid text PRIMARY KEY, balance numeric not null, other text);
diff --git a/src/test/isolation/specs/insert-conflict-specconflict.spec b/src/test/isolation/specs/insert-conflict-specconflict.spec
index 6028397491..4c7dae67e2 100644
--- a/src/test/isolation/specs/insert-conflict-specconflict.spec
+++ b/src/test/isolation/specs/insert-conflict-specconflict.spec
@@ -31,7 +31,7 @@ setup
RETURN $1;
END;$$;
- CREATE OR REPLACE FUNCTION ctoast_large_val() RETURNS TEXT LANGUAGE SQL AS 'select array_agg(md5(g::text))::text from generate_series(1, 256) g';
+ CREATE OR REPLACE FUNCTION ctoast_large_val() RETURNS TEXT LANGUAGE SQLTEST AS 'select array_agg(md5(g::text))::text from generate_series(1, 256) g';
CREATE TABLE upserttest(key text, data text);
diff --git a/src/test/isolation/specs/read-write-unique-3.spec b/src/test/isolation/specs/read-write-unique-3.spec
index 52d287721b..ff8f436df6 100644
--- a/src/test/isolation/specs/read-write-unique-3.spec
+++ b/src/test/isolation/specs/read-write-unique-3.spec
@@ -9,7 +9,7 @@ setup
);
CREATE OR REPLACE FUNCTION insert_unique(k integer, v text) RETURNS void
- LANGUAGE SQL AS $$
+ LANGUAGE SQLTEST AS $$
INSERT INTO test (key, val) SELECT k, v WHERE NOT EXISTS (SELECT key FROM test WHERE key = k);
$$;
}
diff --git a/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out b/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
index b2d898a7d1..816710e58f 100644
--- a/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
+++ b/src/test/modules/dummy_seclabel/expected/dummy_seclabel.out
@@ -12,7 +12,7 @@ CREATE USER regress_dummy_seclabel_user2;
CREATE TABLE dummy_seclabel_tbl1 (a int, b text);
CREATE TABLE dummy_seclabel_tbl2 (x int, y text);
CREATE VIEW dummy_seclabel_view1 AS SELECT * FROM dummy_seclabel_tbl2;
-CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ language sql;
+CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ LANGUAGE SQLTEST;
CREATE DOMAIN dummy_seclabel_domain AS text;
ALTER TABLE dummy_seclabel_tbl1 OWNER TO regress_dummy_seclabel_user1;
ALTER TABLE dummy_seclabel_tbl2 OWNER TO regress_dummy_seclabel_user2;
diff --git a/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql b/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
index 8c347b6a68..a7d607b2be 100644
--- a/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
+++ b/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
@@ -17,7 +17,7 @@ CREATE USER regress_dummy_seclabel_user2;
CREATE TABLE dummy_seclabel_tbl1 (a int, b text);
CREATE TABLE dummy_seclabel_tbl2 (x int, y text);
CREATE VIEW dummy_seclabel_view1 AS SELECT * FROM dummy_seclabel_tbl2;
-CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ language sql;
+CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ LANGUAGE SQLTEST;
CREATE DOMAIN dummy_seclabel_domain AS text;
ALTER TABLE dummy_seclabel_tbl1 OWNER TO regress_dummy_seclabel_user1;
diff --git a/src/test/modules/test_ddl_deparse/expected/create_transform.out b/src/test/modules/test_ddl_deparse/expected/create_transform.out
index 5066051fca..a9831f2564 100644
--- a/src/test/modules/test_ddl_deparse/expected/create_transform.out
+++ b/src/test/modules/test_ddl_deparse/expected/create_transform.out
@@ -8,8 +8,8 @@
-- We choose some random built-in functions that have the right signature.
-- This won't actually be used, because the SQL function language
-- doesn't implement transforms (there would be no point).
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
NOTICE: DDL test: type simple, tag CREATE TRANSFORM
-DROP TRANSFORM FOR int LANGUAGE SQL;
+DROP TRANSFORM FOR int LANGUAGE SQLTEST;
diff --git a/src/test/modules/test_ddl_deparse/expected/opfamily.out b/src/test/modules/test_ddl_deparse/expected/opfamily.out
index 14bd6037cd..d9a882112c 100644
--- a/src/test/modules/test_ddl_deparse/expected/opfamily.out
+++ b/src/test/modules/test_ddl_deparse/expected/opfamily.out
@@ -56,7 +56,7 @@ NOTICE: DDL test: type alter operator family, tag ALTER OPERATOR FAMILY
-- copied from alter_table.sql
create type ctype as (f1 int, f2 text);
NOTICE: DDL test: type simple, tag CREATE TYPE
-create function same(ctype, ctype) returns boolean language sql
+create function same(ctype, ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
NOTICE: DDL test: type simple, tag CREATE FUNCTION
create operator =(procedure = same, leftarg = ctype, rightarg = ctype);
diff --git a/src/test/modules/test_ddl_deparse/sql/create_transform.sql b/src/test/modules/test_ddl_deparse/sql/create_transform.sql
index 970d89e03d..715ee2a06c 100644
--- a/src/test/modules/test_ddl_deparse/sql/create_transform.sql
+++ b/src/test/modules/test_ddl_deparse/sql/create_transform.sql
@@ -9,8 +9,8 @@
-- We choose some random built-in functions that have the right signature.
-- This won't actually be used, because the SQL function language
-- doesn't implement transforms (there would be no point).
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
-DROP TRANSFORM FOR int LANGUAGE SQL;
+DROP TRANSFORM FOR int LANGUAGE SQLTEST;
diff --git a/src/test/modules/test_ddl_deparse/sql/opfamily.sql b/src/test/modules/test_ddl_deparse/sql/opfamily.sql
index b2bacbbcbd..f16bc90bec 100644
--- a/src/test/modules/test_ddl_deparse/sql/opfamily.sql
+++ b/src/test/modules/test_ddl_deparse/sql/opfamily.sql
@@ -42,7 +42,7 @@ alter operator family integer_ops using btree add
-- copied from alter_table.sql
create type ctype as (f1 int, f2 text);
-create function same(ctype, ctype) returns boolean language sql
+create function same(ctype, ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
create operator =(procedure = same, leftarg = ctype, rightarg = ctype);
diff --git a/src/test/modules/test_extensions/test_ext8--1.0.sql b/src/test/modules/test_extensions/test_ext8--1.0.sql
index 1561ffefaa..f75112870a 100644
--- a/src/test/modules/test_extensions/test_ext8--1.0.sql
+++ b/src/test/modules/test_extensions/test_ext8--1.0.sql
@@ -13,9 +13,9 @@ create table ext8_table1 (f1 posint);
create temp table ext8_temp_table1 (f1 posint);
create function ext8_even (posint) returns bool as
- 'select ($1 % 2) = 0' language sql;
+ 'select ($1 % 2) = 0' LANGUAGE SQLTEST;
create function pg_temp.ext8_temp_even (posint) returns bool as
- 'select ($1 % 2) = 0' language sql;
+ 'select ($1 % 2) = 0' LANGUAGE SQLTEST;
-- we intentionally don't drop the temp objects before exiting
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl
index 501aff0920..b05b1f25a2 100644
--- a/src/test/modules/test_pg_dump/t/001_base.pl
+++ b/src/test/modules/test_pg_dump/t/001_base.pl
@@ -564,7 +564,7 @@ my %tests = (
'CREATE FUNCTION regress_pg_dump_schema.test_func' => {
regexp => qr/^
\QCREATE FUNCTION regress_pg_dump_schema.test_func() RETURNS integer\E
- \n\s+\QLANGUAGE sql\E
+ \n\s+\QLANGUAGE sqltest\E
\n/xm,
like => { binary_upgrade => 1, },
},
diff --git a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql
index 110f7eef66..9c9f381ca5 100644
--- a/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql
+++ b/src/test/modules/test_pg_dump/test_pg_dump--1.0.sql
@@ -28,7 +28,7 @@ GRANT SELECT(col1) ON regress_pg_dump_table TO public;
GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role;
REVOKE SELECT(col2) ON regress_pg_dump_table FROM regress_dump_test_role;
-CREATE FUNCTION wgo_then_no_access() RETURNS int LANGUAGE SQL AS 'SELECT 1';
+CREATE FUNCTION wgo_then_no_access() RETURNS int LANGUAGE SQLTEST AS 'SELECT 1';
GRANT ALL ON FUNCTION wgo_then_no_access()
TO pg_signal_backend WITH GRANT OPTION;
@@ -54,7 +54,7 @@ CREATE TYPE regress_pg_dump_schema.test_type AS (col1 int);
GRANT USAGE ON TYPE regress_pg_dump_schema.test_type TO regress_dump_test_role;
CREATE FUNCTION regress_pg_dump_schema.test_func () RETURNS int
-AS 'SELECT 1;' LANGUAGE SQL;
+AS 'SELECT 1;' LANGUAGE SQLTEST;
GRANT EXECUTE ON FUNCTION regress_pg_dump_schema.test_func() TO regress_dump_test_role;
CREATE AGGREGATE regress_pg_dump_schema.test_agg(int2)
diff --git a/src/test/modules/unsafe_tests/expected/rolenames.out b/src/test/modules/unsafe_tests/expected/rolenames.out
index eb608fdc2e..14b0590c74 100644
--- a/src/test/modules/unsafe_tests/expected/rolenames.out
+++ b/src/test/modules/unsafe_tests/expected/rolenames.out
@@ -14,7 +14,7 @@ SELECT r.rolname, v.keyword, r.rolcanlogin, r.rolreplication
AS v(uname, keyword)
ON (r.rolname = v.uname)
ORDER BY 1, 2;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chksetconfig()
RETURNS TABLE (db name, "role" name, rolkeyword text, setconfig text[])
AS $$
@@ -30,7 +30,7 @@ SELECT COALESCE(d.datname, 'ALL'), COALESCE(r.rolname, 'ALL'),
ON (r.rolname = v.uname)
WHERE (r.rolname) IN ('Public', 'current_user', 'regress_testrol1', 'regress_testrol2')
ORDER BY 1, 2, 3;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chkumapping()
RETURNS TABLE (umname name, umserver name, umoptions text[])
AS $$
@@ -39,7 +39,7 @@ SELECT r.rolname, s.srvname, m.umoptions
LEFT JOIN pg_roles r ON (r.oid = m.umuser)
JOIN pg_foreign_server s ON (s.oid = m.umserver)
ORDER BY 2, 1;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
--
-- We test creation and use of these role names to ensure that the server
-- correctly distinguishes role keywords from quoted names that look like
diff --git a/src/test/modules/unsafe_tests/sql/rolenames.sql b/src/test/modules/unsafe_tests/sql/rolenames.sql
index adac36536d..a02fc6ae20 100644
--- a/src/test/modules/unsafe_tests/sql/rolenames.sql
+++ b/src/test/modules/unsafe_tests/sql/rolenames.sql
@@ -14,7 +14,7 @@ SELECT r.rolname, v.keyword, r.rolcanlogin, r.rolreplication
AS v(uname, keyword)
ON (r.rolname = v.uname)
ORDER BY 1, 2;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chksetconfig()
RETURNS TABLE (db name, "role" name, rolkeyword text, setconfig text[])
@@ -31,7 +31,7 @@ SELECT COALESCE(d.datname, 'ALL'), COALESCE(r.rolname, 'ALL'),
ON (r.rolname = v.uname)
WHERE (r.rolname) IN ('Public', 'current_user', 'regress_testrol1', 'regress_testrol2')
ORDER BY 1, 2, 3;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION chkumapping()
RETURNS TABLE (umname name, umserver name, umoptions text[])
@@ -41,7 +41,7 @@ SELECT r.rolname, s.srvname, m.umoptions
LEFT JOIN pg_roles r ON (r.oid = m.umuser)
JOIN pg_foreign_server s ON (s.oid = m.umserver)
ORDER BY 2, 1;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
--
-- We test creation and use of these role names to ensure that the server
diff --git a/src/test/regress/expected/alter_generic.out b/src/test/regress/expected/alter_generic.out
index 505eb7ede5..fe47e5c11a 100644
--- a/src/test/regress/expected/alter_generic.out
+++ b/src/test/regress/expected/alter_generic.out
@@ -18,9 +18,9 @@ SET search_path = alt_nsp1, public;
-- Function and Aggregate
--
SET SESSION AUTHORIZATION regress_alter_generic_user1;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 1';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 1';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0
@@ -50,9 +50,9 @@ ERROR: must be member of role "regress_alter_generic_user2"
ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3; -- OK
ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2; -- OK
SET SESSION AUTHORIZATION regress_alter_generic_user2;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 2';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 2';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100
@@ -410,7 +410,7 @@ DROP OPERATOR FAMILY alt_opf11 USING gist;
-- Should fail. btree comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf12 USING btree;
-CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2);
ERROR: btree comparison functions must return integer
DROP OPERATOR FAMILY alt_opf12 USING btree;
@@ -419,7 +419,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf13 USING hash;
-CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4);
ERROR: hash function 1 must return integer
DROP OPERATOR FAMILY alt_opf13 USING hash;
@@ -428,7 +428,7 @@ ROLLBACK;
-- Should fail. btree comparison functions should have two arguments in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf14 USING btree;
-CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4);
ERROR: btree comparison functions must have two arguments
DROP OPERATOR FAMILY alt_opf14 USING btree;
@@ -437,7 +437,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should have one argument in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf15 USING hash;
-CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2);
ERROR: hash function 1 must have one argument
DROP OPERATOR FAMILY alt_opf15 USING hash;
diff --git a/src/test/regress/expected/alter_operator.out b/src/test/regress/expected/alter_operator.out
index 71bd484282..f66351528c 100644
--- a/src/test/regress/expected/alter_operator.out
+++ b/src/test/regress/expected/alter_operator.out
@@ -1,5 +1,5 @@
CREATE FUNCTION alter_op_test_fn(boolean, boolean)
-RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
+RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sqltest IMMUTABLE;
CREATE FUNCTION customcontsel(internal, oid, internal, integer)
RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT;
CREATE OPERATOR === (
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 0ce6ee4622..df6fa3b29b 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2804,7 +2804,7 @@ drop type lockmodes;
--
create function test_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql returns null on null input;
+ LANGUAGE SQLTEST returns null on null input;
select test_strict(NULL);
test_strict
-------------
@@ -2820,7 +2820,7 @@ select test_strict(NULL);
create function non_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql called on null input;
+ LANGUAGE SQLTEST called on null input;
select non_strict(NULL);
non_strict
-------------------
@@ -2841,10 +2841,10 @@ create schema alter1;
create schema alter2;
create table alter1.t1(f1 serial primary key, f2 int check (f2 > 0));
create view alter1.v1 as select * from alter1.t1;
-create function alter1.plus1(int) returns int as 'select $1+1' language sql;
+create function alter1.plus1(int) returns int as 'select $1+1' LANGUAGE SQLTEST;
create domain alter1.posint integer check (value > 0);
create type alter1.ctype as (f1 int, f2 text);
-create function alter1.same(alter1.ctype, alter1.ctype) returns boolean language sql
+create function alter1.same(alter1.ctype, alter1.ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
create operator alter1.=(procedure = alter1.same, leftarg = alter1.ctype, rightarg = alter1.ctype);
create operator class alter1.ctype_hash_ops default for type alter1.ctype using hash as
@@ -4338,7 +4338,7 @@ drop function func_part_attach();
-- test case where the partitioning operator is a SQL function whose
-- evaluation results in the table's relcache being rebuilt partway through
-- the execution of an ATTACH PARTITION command
-create function at_test_sql_partop (int4, int4) returns int language sql
+create function at_test_sql_partop (int4, int4) returns int LANGUAGE SQLTEST
as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$;
create operator class at_test_sql_partop for type int4 using btree as
operator 1 < (int4, int4), operator 2 <= (int4, int4),
diff --git a/src/test/regress/expected/arrays.out b/src/test/regress/expected/arrays.out
index 8bc7721e7d..110eb283d1 100644
--- a/src/test/regress/expected/arrays.out
+++ b/src/test/regress/expected/arrays.out
@@ -1580,12 +1580,12 @@ drop type comptype;
create or replace function unnest1(anyarray)
returns setof anyelement as $$
select $1[s] from generate_subscripts($1,1) g(s);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create or replace function unnest2(anyarray)
returns setof anyelement as $$
select $1[s1][s2] from generate_subscripts($1,1) g1(s1),
generate_subscripts($1,2) g2(s2);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select * from unnest1(array[1,2,3]);
unnest1
---------
diff --git a/src/test/regress/expected/case.out b/src/test/regress/expected/case.out
index 7fcfe9a7a6..b46fd1d378 100644
--- a/src/test/regress/expected/case.out
+++ b/src/test/regress/expected/case.out
@@ -337,7 +337,7 @@ CREATE DOMAIN foodomain AS text;
CREATE FUNCTION volfoo(text) returns foodomain as
'begin return $1::foodomain; end' language plpgsql volatile;
CREATE FUNCTION inline_eq(foodomain, foodomain) returns boolean as
- 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' language sql;
+ 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' LANGUAGE SQLTEST;
CREATE OPERATOR = (procedure = inline_eq,
leftarg = foodomain, rightarg = foodomain);
SELECT CASE volfoo('bar') WHEN 'foo'::foodomain THEN 'is foo' ELSE 'is not foo' END;
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index bc3752e923..41ea82261d 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -811,9 +811,9 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
AS $$ begin return $1 < $2; end $$;
@@ -935,7 +935,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER
(4 rows)
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
a | dup
---+-----
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index 580b00eea7..fa91f76dc1 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -848,9 +848,9 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
AS $$ begin return $1 < $2; end $$;
@@ -972,7 +972,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER
(4 rows)
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
a | dup
---+-----
diff --git a/src/test/regress/expected/collate.out b/src/test/regress/expected/collate.out
index c42ab8f703..4279c6e9d0 100644
--- a/src/test/regress/expected/collate.out
+++ b/src/test/regress/expected/collate.out
@@ -537,7 +537,7 @@ SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2;
(4 rows)
-- result of a SQL function
-CREATE FUNCTION vc (text) RETURNS text LANGUAGE sql
+CREATE FUNCTION vc (text) RETURNS text LANGUAGE sqltest
AS 'select $1::varchar';
SELECT a, b FROM collate_test1 ORDER BY a, vc(b);
a | b
@@ -568,7 +568,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER
(4 rows)
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
a | dup
---+-----
diff --git a/src/test/regress/expected/create_aggregate.out b/src/test/regress/expected/create_aggregate.out
index dcf6909423..0236cfbed1 100644
--- a/src/test/regress/expected/create_aggregate.out
+++ b/src/test/regress/expected/create_aggregate.out
@@ -38,7 +38,7 @@ COMMENT ON AGGREGATE newcnt (*) IS 'an agg(*) comment';
COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment';
-- multi-argument aggregate
create function sum3(int8,int8,int8) returns int8 as
-'select $1 + $2 + $3' language sql strict immutable;
+'select $1 + $2 + $3' LANGUAGE SQLTEST strict immutable;
create aggregate sum2(int8,int8) (
sfunc = sum3, stype = int8,
initcond = '0'
@@ -47,10 +47,10 @@ create aggregate sum2(int8,int8) (
create type aggtype as (a integer, b integer, c text);
create function aggf_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql strict immutable;
+LANGUAGE SQLTEST strict immutable;
create function aggfns_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql immutable;
+LANGUAGE SQLTEST immutable;
create aggregate aggfstr(integer,integer,text) (
sfunc = aggf_trans, stype = aggtype[],
initcond = '{}'
@@ -60,7 +60,7 @@ create aggregate aggfns(integer,integer,text) (
initcond = '{}'
);
-- check error cases that would require run-time type coercion
-create function least_accum(int8, int8) returns int8 language sql as
+create function least_accum(int8, int8) returns int8 LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
stype = int8, sfunc = least_accum
@@ -68,7 +68,7 @@ create aggregate least_agg(int4) (
ERROR: function least_accum(bigint, bigint) requires run-time type coercion
drop function least_accum(int8, int8);
create function least_accum(anycompatible, anycompatible)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
stype = int8, sfunc = least_accum
@@ -81,13 +81,13 @@ drop function least_accum(anycompatible, anycompatible) cascade;
NOTICE: drop cascades to function least_agg(bigint)
-- variadic aggregates
create function least_accum(anyelement, variadic anyarray)
-returns anyelement language sql as
+returns anyelement LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate least_agg(variadic items anyarray) (
stype = anyelement, sfunc = least_accum
);
create function cleast_accum(anycompatible, variadic anycompatiblearray)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate cleast_agg(variadic items anycompatiblearray) (
stype = anycompatible, sfunc = cleast_accum
@@ -248,7 +248,7 @@ ERROR: cannot change routine kind
DETAIL: "myavg" is an ordinary aggregate function.
-- can't change plain function to aggregate:
create function sum4(int8,int8,int8,int8) returns int8 as
-'select $1 + $2 + $3 + $4' language sql strict immutable;
+'select $1 + $2 + $3 + $4' LANGUAGE SQLTEST strict immutable;
CREATE OR REPLACE AGGREGATE sum3 (int8,int8,int8)
(
stype = int8,
@@ -269,7 +269,7 @@ ERROR: parameter "parallel" must be SAFE, RESTRICTED, or UNSAFE
-- invalid: nonstrict inverse with strict forward function
CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS
$$ SELECT $1 - $2; $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE invalidsumdouble (float8)
(
stype = float8,
@@ -282,7 +282,7 @@ ERROR: strictness of aggregate's forward and inverse transition functions must
-- invalid: non-matching result types
CREATE FUNCTION float8mi_int(float8, float8) RETURNS int AS
$$ SELECT CAST($1 - $2 AS INT); $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE wrongreturntype (float8)
(
stype = float8,
diff --git a/src/test/regress/expected/create_cast.out b/src/test/regress/expected/create_cast.out
index 88f94a63b4..cebb491053 100644
--- a/src/test/regress/expected/create_cast.out
+++ b/src/test/regress/expected/create_cast.out
@@ -20,7 +20,7 @@ CREATE TYPE casttesttype (
alignment = int4
);
-- a dummy function to test with
-CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQL AS
+CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQLTEST AS
$$ SELECT 1; $$;
SELECT casttestfunc('foo'::text); -- fails, as there's no cast
ERROR: function casttestfunc(text) does not exist
@@ -63,7 +63,7 @@ SELECT 1234::int4::casttesttype; -- Should work now
DROP CAST (int4 AS casttesttype);
-- Try cast with a function
-CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQL AS
+CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQLTEST AS
$$ SELECT ('foo'::text || $1::text)::casttesttype; $$;
CREATE CAST (int4 AS casttesttype) WITH FUNCTION int4_casttesttype(int4) AS IMPLICIT;
SELECT 1234::int4::casttesttype; -- Should work now
diff --git a/src/test/regress/expected/create_function_3.out b/src/test/regress/expected/create_function_3.out
index ce508ae1dc..6a25967db2 100644
--- a/src/test/regress/expected/create_function_3.out
+++ b/src/test/regress/expected/create_function_3.out
@@ -14,11 +14,11 @@ SET search_path TO temp_func_test, public;
--
-- ARGUMENT and RETURN TYPES
--
-CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
-CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
+CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sqltest'
AS 'SELECT $1[1]::int';
-CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT false';
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
WHERE oid in ('functest_A_1'::regproc,
@@ -52,13 +52,13 @@ SELECT functest_A_3();
--
-- IMMUTABLE | STABLE | VOLATILE
--
-CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sqltest'
STABLE AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sqltest'
VOLATILE AS 'SELECT $1 < 0';
SELECT proname, provolatile FROM pg_proc
WHERE oid in ('functest_B_1'::regproc,
@@ -91,11 +91,11 @@ SELECT proname, provolatile FROM pg_proc
--
-- SECURITY DEFINER | INVOKER
--
-CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY DEFINER AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY INVOKER AS 'SELECT $1 < 0';
SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functest_C_1'::regproc,
@@ -125,9 +125,9 @@ SELECT proname, prosecdef FROM pg_proc
--
-- LEAKPROOF
--
-CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 100';
-CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 > 100';
SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functest_E_1'::regproc,
@@ -167,20 +167,20 @@ SET search_path TO temp_func_test, public;
ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF;
ALTER FUNCTION functest_E_2(int) LEAKPROOF;
ERROR: only superuser can define a leakproof function
-CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 < 200'; -- fail
ERROR: only superuser can define a leakproof function
RESET SESSION AUTHORIZATION;
--
-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
--
-CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 50';
-CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sqltest'
CALLED ON NULL INPUT AS 'SELECT $1 = 50';
-CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sqltest'
RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50';
-CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sqltest'
STRICT AS 'SELECT $1 = 50';
SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functest_F_1'::regproc,
@@ -217,7 +217,7 @@ SELECT pg_get_functiondef('functest_A_1'::regproc);
--------------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_a_1(text, date)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
AS $function$SELECT $1 = 'abcd' AND $2 > '2001-01-01'$function$ +
(1 row)
@@ -227,7 +227,7 @@ SELECT pg_get_functiondef('functest_B_3'::regproc);
-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_b_3(integer)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
STABLE +
AS $function$SELECT $1 = 0$function$ +
@@ -238,7 +238,7 @@ SELECT pg_get_functiondef('functest_C_3'::regproc);
-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_c_3(integer)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
SECURITY DEFINER +
AS $function$SELECT $1 < 0$function$ +
@@ -249,7 +249,7 @@ SELECT pg_get_functiondef('functest_F_2'::regproc);
-----------------------------------------------------------------
CREATE OR REPLACE FUNCTION temp_func_test.functest_f_2(integer)+
RETURNS boolean +
- LANGUAGE sql +
+ LANGUAGE sqltest +
STRICT +
AS $function$SELECT $1 = 50$function$ +
@@ -258,15 +258,15 @@ SELECT pg_get_functiondef('functest_F_2'::regproc);
-- information_schema tests
CREATE FUNCTION functest_IS_1(a int, b int default 1, c text default 'foo')
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1 + $2';
CREATE FUNCTION functest_IS_2(out a int, b int default 1)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
CREATE FUNCTION functest_IS_3(a int default 1, out b int)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
SELECT routine_name, ordinal_position, parameter_name, parameter_default
FROM information_schema.parameters JOIN information_schema.routines USING (specific_schema, specific_name)
@@ -285,7 +285,7 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
-- overload
-CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
DROP FUNCTION functest_b_1;
DROP FUNCTION functest_b_1; -- error, not found
@@ -294,16 +294,16 @@ DROP FUNCTION functest_b_2; -- error, ambiguous
ERROR: function name "functest_b_2" is not unique
HINT: Specify the argument list to select the function unambiguously.
-- CREATE OR REPLACE tests
-CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL AS 'SELECT $1';
-CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL WINDOW AS 'SELECT $1';
+CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST AS 'SELECT $1';
+CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST WINDOW AS 'SELECT $1';
ERROR: cannot change routine kind
DETAIL: "functest1" is a function.
-CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQL AS 'SELECT $1';
+CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQLTEST AS 'SELECT $1';
ERROR: cannot change routine kind
DETAIL: "functest1" is a function.
DROP FUNCTION functest1(a int);
-- Check behavior of VOID-returning SQL functions
-CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT a + 1 $$;
SELECT voidtest1(42);
voidtest1
@@ -311,7 +311,7 @@ SELECT voidtest1(42);
(1 row)
-CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT voidtest1(a + b) $$;
SELECT voidtest2(11,22);
voidtest2
@@ -328,7 +328,7 @@ EXPLAIN (verbose, costs off) SELECT voidtest2(11,22);
(2 rows)
CREATE TEMP TABLE sometable(f1 int);
-CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a + 1) $$;
SELECT voidtest3(17);
voidtest3
@@ -336,7 +336,7 @@ SELECT voidtest3(17);
(1 row)
-CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a - 1) RETURNING f1 $$;
SELECT voidtest4(39);
voidtest4
@@ -351,7 +351,7 @@ TABLE sometable;
38
(2 rows)
-CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQLTEST AS
$$ SELECT generate_series(1, a) $$ STABLE;
SELECT * FROM voidtest5(3);
voidtest5
diff --git a/src/test/regress/expected/create_operator.out b/src/test/regress/expected/create_operator.out
index 5303277591..93aa09a3e2 100644
--- a/src/test/regress/expected/create_operator.out
+++ b/src/test/regress/expected/create_operator.out
@@ -167,7 +167,7 @@ BEGIN TRANSACTION;
CREATE OR REPLACE FUNCTION fn_op2(boolean, boolean)
RETURNS boolean AS $$
SELECT NULL::BOOLEAN;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
CREATE OPERATOR === (
LEFTARG = boolean,
RIGHTARG = boolean,
@@ -203,7 +203,7 @@ CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op3(type_op3, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op3 FROM regress_rol_op3;
REVOKE USAGE ON TYPE type_op3 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op3;
@@ -221,7 +221,7 @@ CREATE TYPE type_op4 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op4(int8, type_op4)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op4 FROM regress_rol_op4;
REVOKE USAGE ON TYPE type_op4 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op4;
@@ -239,7 +239,7 @@ CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op5(int8, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM PUBLIC;-- Need to do this so that regress_rol_op3 is not allowed EXECUTE via PUBLIC
SET ROLE regress_rol_op5;
@@ -257,7 +257,7 @@ CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op6(int8, int8)
RETURNS type_op6 AS $$
SELECT NULL::type_op6;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op6 FROM regress_rol_op6;
REVOKE USAGE ON TYPE type_op6 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op6;
diff --git a/src/test/regress/expected/create_procedure.out b/src/test/regress/expected/create_procedure.out
index 3838fa2324..82af83c4d2 100644
--- a/src/test/regress/expected/create_procedure.out
+++ b/src/test/regress/expected/create_procedure.out
@@ -8,10 +8,10 @@ ERROR: random() is not a procedure
LINE 1: CALL random();
^
HINT: To call a function, use SELECT.
-CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQL AS $$ SELECT a $$;
+CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQLTEST AS $$ SELECT a $$;
CREATE TABLE cp_test (a int, b text);
CREATE PROCEDURE ptest1(x text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, x);
$$;
@@ -26,7 +26,7 @@ SELECT pg_get_functiondef('ptest1'::regproc);
pg_get_functiondef
---------------------------------------------------
CREATE OR REPLACE PROCEDURE public.ptest1(x text)+
- LANGUAGE sql +
+ LANGUAGE sqltest +
AS $procedure$ +
INSERT INTO cp_test VALUES (1, x); +
$procedure$ +
@@ -66,7 +66,7 @@ SELECT * FROM cp_test ORDER BY b COLLATE "C";
(3 rows)
CREATE PROCEDURE ptest2()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 5;
$$;
@@ -74,7 +74,7 @@ CALL ptest2();
-- nested CALL
TRUNCATE cp_test;
CREATE PROCEDURE ptest3(y text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest1(y);
CALL ptest1($1);
@@ -89,7 +89,7 @@ SELECT * FROM cp_test;
-- output arguments
CREATE PROCEDURE ptest4a(INOUT a int, INOUT b int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 1, 2;
$$;
@@ -100,7 +100,7 @@ CALL ptest4a(NULL, NULL);
(1 row)
CREATE PROCEDURE ptest4b(INOUT b int, INOUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest4a(a, b); -- error, not supported
$$;
@@ -109,7 +109,7 @@ CONTEXT: SQL function "ptest4b"
DROP PROCEDURE ptest4a;
-- named and default parameters
CREATE OR REPLACE PROCEDURE ptest5(a int, b text, c int default 100)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES(a, b);
INSERT INTO cp_test VALUES(c, b);
@@ -134,21 +134,21 @@ SELECT * FROM cp_test;
-- polymorphic types
CREATE PROCEDURE ptest6(a int, b anyelement)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT NULL::int;
$$;
CALL ptest6(1, 2);
-- collation assignment
CREATE PROCEDURE ptest7(a text, b text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT a = b;
$$;
CALL ptest7(least('a', 'b'), 'a');
-- OUT parameters
CREATE PROCEDURE ptest9(OUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, 'a');
SELECT 1;
@@ -170,13 +170,13 @@ ERROR: sum(integer) is not a procedure
LINE 1: CALL sum(1);
^
HINT: To call a function, use SELECT.
-CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
ERROR: invalid attribute in procedure definition
-LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT I...
+LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQLTEST WINDOW AS $$ INSERT I...
^
-CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
ERROR: invalid attribute in procedure definition
-LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT I...
+LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQLTEST STRICT AS $$ INSERT I...
^
ALTER PROCEDURE ptest1(text) STRICT;
ERROR: invalid attribute in procedure definition
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index ed8c01b8de..65aee00962 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -367,7 +367,7 @@ ERROR: exclusion constraints are not supported on partitioned tables
LINE 3: EXCLUDE USING gist (a WITH &&)
^
-- prevent using prohibited expressions in the key
-CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (retset(a));
@@ -390,7 +390,7 @@ CREATE TABLE partitioned (
a int
) PARTITION BY RANGE ((42));
ERROR: cannot use constant expression as partition key
-CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (const_func());
@@ -427,7 +427,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a, ('unknown'));
ERROR: partition key column 2 has pseudo-type unknown
-- functions in key must be immutable
-CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL;
+CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (immut_func(a));
@@ -459,7 +459,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a);
ERROR: cannot add NO INHERIT constraint to partitioned table "partitioned"
-- some checks after successful creation of a partitioned table
-CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL;
+CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int,
b int,
@@ -1149,7 +1149,7 @@ Partition constraint: ((abs(a) IS NOT NULL) AND (abs(b) IS NOT NULL) AND (c IS N
DROP TABLE range_parted4;
-- user-defined operator class in partition key
-CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql
+CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sqltest
AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$;
CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS
OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4),
diff --git a/src/test/regress/expected/create_type.out b/src/test/regress/expected/create_type.out
index 14394cc95c..3f4f6ee65f 100644
--- a/src/test/regress/expected/create_type.out
+++ b/src/test/regress/expected/create_type.out
@@ -131,7 +131,7 @@ HINT: Create the type as a shell type, then create its I/O functions, then do a
CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42);
CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS '
SELECT * FROM default_test;
-' LANGUAGE SQL;
+' LANGUAGE SQLTEST;
SELECT * FROM get_default_test();
f1 | f2
-------+----
diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out
index 411d5c003e..fc56c69d8b 100644
--- a/src/test/regress/expected/domain.out
+++ b/src/test/regress/expected/domain.out
@@ -1067,7 +1067,7 @@ drop domain di;
-- this has caused issues in the past
--
create function sql_is_distinct_from(anyelement, anyelement)
-returns boolean language sql
+returns boolean LANGUAGE SQLTEST
as 'select $1 is distinct from $2 limit 1';
create domain inotnull int
check (sql_is_distinct_from(value, null));
diff --git a/src/test/regress/expected/drop_if_exists.out b/src/test/regress/expected/drop_if_exists.out
index 5e44c2c3ce..e4b45fe0df 100644
--- a/src/test/regress/expected/drop_if_exists.out
+++ b/src/test/regress/expected/drop_if_exists.out
@@ -303,8 +303,8 @@ DROP VIEW IF EXISTS no_such_schema.foo;
NOTICE: schema "no_such_schema" does not exist, skipping
-- Check we receive an ambiguous function error when there are
-- multiple matching functions.
-CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ language sql;
-CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ language sql;
+CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ LANGUAGE SQLTEST;
+CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ LANGUAGE SQLTEST;
DROP FUNCTION test_ambiguous_funcname;
ERROR: function name "test_ambiguous_funcname" is not unique
HINT: Specify the argument list to select the function unambiguously.
diff --git a/src/test/regress/expected/event_trigger.out b/src/test/regress/expected/event_trigger.out
index bdd0ffcdaf..9bcb2a56ab 100644
--- a/src/test/regress/expected/event_trigger.out
+++ b/src/test/regress/expected/event_trigger.out
@@ -20,7 +20,7 @@ ERROR: event trigger functions cannot have declared arguments
CONTEXT: compilation of PL/pgSQL function "test_event_trigger_arg" near line 1
-- should fail, SQL functions cannot be event triggers
create function test_event_trigger_sql() returns event_trigger as $$
-SELECT 1 $$ language sql;
+SELECT 1 $$ LANGUAGE SQLTEST;
ERROR: SQL functions cannot return type event_trigger
-- should fail, no elephant_bootstrap entry point
create event trigger regress_event_trigger on elephant_bootstrap
diff --git a/src/test/regress/expected/foreign_data.out b/src/test/regress/expected/foreign_data.out
index b9e25820bc..d3e4a45b7f 100644
--- a/src/test/regress/expected/foreign_data.out
+++ b/src/test/regress/expected/foreign_data.out
@@ -90,7 +90,7 @@ CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator;
(3 rows)
-- HANDLER related checks
-CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;';
+CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQLTEST AS 'SELECT 1;';
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler; -- ERROR
ERROR: function invalid_fdw_handler must return type fdw_handler
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR
diff --git a/src/test/regress/expected/generated.out b/src/test/regress/expected/generated.out
index ca721d38bf..ad1f9c2f11 100644
--- a/src/test/regress/expected/generated.out
+++ b/src/test/regress/expected/generated.out
@@ -463,7 +463,7 @@ CREATE USER regress_user11;
CREATE TABLE gtest11s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (b * 2) STORED);
INSERT INTO gtest11s VALUES (1, 10), (2, 20);
GRANT SELECT (a, c) ON gtest11s TO regress_user11;
-CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQL;
+CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQLTEST;
REVOKE ALL ON FUNCTION gf1(int) FROM PUBLIC;
CREATE TABLE gtest12s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (gf1(b)) STORED);
INSERT INTO gtest12s VALUES (1, 10), (2, 20);
diff --git a/src/test/regress/expected/guc.out b/src/test/regress/expected/guc.out
index 811f80a097..7dfefc246c 100644
--- a/src/test/regress/expected/guc.out
+++ b/src/test/regress/expected/guc.out
@@ -641,7 +641,7 @@ reset search_path;
--
set work_mem = '3MB';
create function report_guc(text) returns text as
-$$ select current_setting($1) $$ language sql
+$$ select current_setting($1) $$ LANGUAGE SQLTEST
set work_mem = '1MB';
select report_guc('work_mem'), current_setting('work_mem');
report_guc | current_setting
@@ -760,13 +760,13 @@ select current_setting('nosuch.setting', true);
-- function SET options; but not if check_function_bodies is off,
-- because that creates ordering hazards for pg_dump
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
NOTICE: text search configuration "no_such_config" does not exist
ERROR: invalid value for parameter "default_text_search_config": "no_such_config"
set check_function_bodies = off;
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
NOTICE: text search configuration "no_such_config" does not exist
select func_with_bad_set();
diff --git a/src/test/regress/expected/infinite_recurse.out b/src/test/regress/expected/infinite_recurse.out
index aa102fadd8..0f4894b057 100644
--- a/src/test/regress/expected/infinite_recurse.out
+++ b/src/test/regress/expected/infinite_recurse.out
@@ -1,7 +1,7 @@
-- Check that stack depth detection mechanism works and
-- max_stack_depth is not set too high.
create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
+'select infinite_recurse()' LANGUAGE SQLTEST;
-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
-- signal handling that would cause this test to crash if it happened
-- to receive an sinval catchup interrupt while the stack is deep:
diff --git a/src/test/regress/expected/infinite_recurse_1.out b/src/test/regress/expected/infinite_recurse_1.out
index b2c99a0d0d..1c27271a46 100644
--- a/src/test/regress/expected/infinite_recurse_1.out
+++ b/src/test/regress/expected/infinite_recurse_1.out
@@ -1,7 +1,7 @@
-- Check that stack depth detection mechanism works and
-- max_stack_depth is not set too high.
create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
+'select infinite_recurse()' LANGUAGE SQLTEST;
-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
-- signal handling that would cause this test to crash if it happened
-- to receive an sinval catchup interrupt while the stack is deep:
diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out
index 2b68aef654..677e3c9bf8 100644
--- a/src/test/regress/expected/inherit.out
+++ b/src/test/regress/expected/inherit.out
@@ -810,7 +810,7 @@ drop table derived;
drop table base;
create table p1(ff1 int);
create table p2(f1 text);
-create function p2text(p2) returns text as 'select $1.f1' language sql;
+create function p2text(p2) returns text as 'select $1.f1' LANGUAGE SQLTEST;
create table c1(f3 int) inherits(p1,p2);
insert into c1 values(123456789, 'hi', 42);
select p2text(c1.*) from c1;
diff --git a/src/test/regress/expected/insert.out b/src/test/regress/expected/insert.out
index da50ee3b67..fdd7881335 100644
--- a/src/test/regress/expected/insert.out
+++ b/src/test/regress/expected/insert.out
@@ -394,7 +394,7 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
create or replace function part_hashint4_noop(value int4, seed int8)
returns int8 as $$
select value + seed;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_int4_ops
for type int4
using hash as
@@ -403,7 +403,7 @@ function 2 part_hashint4_noop(int4, int8);
create or replace function part_hashtext_length(value text, seed int8)
RETURNS int8 AS $$
select length(coalesce(value, ''))::int8
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_text_ops
for type text
using hash as
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index 5c7528c029..3ef8672618 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -3494,9 +3494,9 @@ where nt3.id = 1 and ss2.b3;
drop function f_immutable_int4(int);
-- test inlining when function returns composite
create function mki8(bigint, bigint) returns int8_tbl as
-$$select row($1,$2)::int8_tbl$$ language sql;
+$$select row($1,$2)::int8_tbl$$ LANGUAGE SQLTEST;
create function mki4(int) returns int4_tbl as
-$$select row($1)::int4_tbl$$ language sql;
+$$select row($1)::int4_tbl$$ LANGUAGE SQLTEST;
explain (verbose, costs off)
select * from mki8(1,2);
QUERY PLAN
diff --git a/src/test/regress/expected/multirangetypes.out b/src/test/regress/expected/multirangetypes.out
index 04953a5990..656c867d20 100644
--- a/src/test/regress/expected/multirangetypes.out
+++ b/src/test/regress/expected/multirangetypes.out
@@ -2735,7 +2735,7 @@ drop type textrange2;
-- Test polymorphic type system
--
create function anyarray_anymultirange_func(a anyarray, r anymultirange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anymultirange_func(ARRAY[1,2], int4multirange(int4range(10,20)));
anyarray_anymultirange_func
-----------------------------
@@ -2751,16 +2751,16 @@ HINT: No function matches the given name and argument types. You might need to
drop function anyarray_anymultirange_func(anyarray, anymultirange);
-- should fail
create function bogus_func(anyelement)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
-- should fail
create function bogus_func(int)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
create function range_add_bounds(anymultirange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4multirange(int4range(1, 17)));
range_add_bounds
------------------
@@ -2775,7 +2775,7 @@ select range_add_bounds(nummultirange(numrange(1.0001, 123.123)));
create function multirangetypes_sql(q anymultirange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select multirangetypes_sql(int4multirange(int4range(1,10)), ARRAY[2,20]);
multirangetypes_sql
---------------------
@@ -2788,7 +2788,7 @@ LINE 1: select multirangetypes_sql(nummultirange(numrange(1,10)), AR...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
create function anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompatiblemultirange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(int4range(10,20)));
anycompatiblearray_anycompatiblemultirange_func
-------------------------------------------------
@@ -2809,7 +2809,7 @@ LINE 1: select anycompatiblearray_anycompatiblemultirange_func(ARRAY...
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
drop function anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemultirange);
create function anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompatiblemultirange)
- returns anycompatible as 'select lower($1) + lower($2);' language sql;
+ returns anycompatible as 'select lower($1) + lower($2);' LANGUAGE SQLTEST;
select anycompatiblerange_anycompatiblemultirange_func(int4range(1,2), multirange(int4range(10,20)));
anycompatiblerange_anycompatiblemultirange_func
-------------------------------------------------
@@ -2825,7 +2825,7 @@ HINT: No function matches the given name and argument types. You might need to
drop function anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange, anycompatiblemultirange);
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
--
@@ -2902,7 +2902,7 @@ reset enable_sort;
--
-- infer anymultirange from anymultirange
create function mr_outparam_succeed(i anymultirange, out r anymultirange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed(int4multirange(int4range(1,2)));
r | t
---------+-----
@@ -2911,7 +2911,7 @@ select * from mr_outparam_succeed(int4multirange(int4range(1,2)));
-- infer anyarray from anymultirange
create function mr_outparam_succeed2(i anymultirange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed2(int4multirange(int4range(1,2)));
r | t
-----+-----
@@ -2920,7 +2920,7 @@ select * from mr_outparam_succeed2(int4multirange(int4range(1,2)));
-- infer anyrange from anymultirange
create function mr_outparam_succeed3(i anymultirange, out r anyrange, out t text)
- as $$ select range_merge($1), 'foo'::text $$ language sql;
+ as $$ select range_merge($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed3(int4multirange(int4range(1,2)));
r | t
-------+-----
@@ -2929,7 +2929,7 @@ select * from mr_outparam_succeed3(int4multirange(int4range(1,2)));
-- infer anymultirange from anyrange
create function mr_outparam_succeed4(i anyrange, out r anymultirange, out t text)
- as $$ select multirange($1), 'foo'::text $$ language sql;
+ as $$ select multirange($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed4(int4range(1,2));
r | t
---------+-----
@@ -2938,7 +2938,7 @@ select * from mr_outparam_succeed4(int4range(1,2));
-- infer anyelement from anymultirange
create function mr_inoutparam_succeed(out i anyelement, inout r anymultirange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from mr_inoutparam_succeed(int4multirange(int4range(1,2)));
i | r
---+---------
@@ -2947,7 +2947,7 @@ select * from mr_inoutparam_succeed(int4multirange(int4range(1,2)));
-- infer anyelement+anymultirange from anyelement+anymultirange
create function mr_table_succeed(i anyelement, r anymultirange) returns table(i anyelement, r anymultirange)
- as $$ select $1, $2 $$ language sql;
+ as $$ select $1, $2 $$ LANGUAGE SQLTEST;
select * from mr_table_succeed(123, int4multirange(int4range(1,11)));
i | r
-----+----------
@@ -2965,16 +2965,16 @@ select mr_polymorphic(int4range(1, 4));
-- should fail
create function mr_outparam_fail(i anyelement, out r anymultirange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
--should fail
create function mr_inoutparam_fail(inout i anyelement, out r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
--should fail
create function mr_table_fail(i anyelement) returns table(i anyelement, r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anymultirange requires at least one input of type anyrange or anymultirange.
diff --git a/src/test/regress/expected/object_address.out b/src/test/regress/expected/object_address.out
index 388097a695..a03756e41b 100644
--- a/src/test/regress/expected/object_address.out
+++ b/src/test/regress/expected/object_address.out
@@ -32,14 +32,14 @@ CREATE DOMAIN addr_nsp.gendomain AS int4 CONSTRAINT domconstr CHECK (value > 0);
CREATE FUNCTION addr_nsp.trig() RETURNS TRIGGER LANGUAGE plpgsql AS $$ BEGIN END; $$;
CREATE TRIGGER t BEFORE INSERT ON addr_nsp.gentable FOR EACH ROW EXECUTE PROCEDURE addr_nsp.trig();
CREATE POLICY genpol ON addr_nsp.gentable;
-CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQL AS $$ $$;
+CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQLTEST AS $$ $$;
CREATE SERVER "integer" FOREIGN DATA WRAPPER addr_fdw;
CREATE USER MAPPING FOR regress_addr_user SERVER "integer";
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regress_addr_user;
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM regress_addr_user;
-- this transform would be quite unsafe to leave lying around,
-- except that the SQL language pays no attention to transforms:
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
-- suppress warning that depends on wal_level
@@ -482,7 +482,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
policy | | | genpol on addr_nsp.gentable | t
statistics object | addr_nsp | gentable_stat | addr_nsp.gentable_stat | t
collation | pg_catalog | "default" | pg_catalog."default" | t
- transform | | | for integer on language sql | t
+ transform | | | for integer on LANGUAGE SQLTEST | t
text search dictionary | addr_nsp | addr_ts_dict | addr_nsp.addr_ts_dict | t
text search parser | addr_nsp | addr_ts_prs | addr_nsp.addr_ts_prs | t
text search configuration | addr_nsp | addr_ts_conf | addr_nsp.addr_ts_conf | t
@@ -569,7 +569,7 @@ WITH objects (classid, objid, objsubid) AS (VALUES
('pg_policy'::regclass, 0, 0), -- no policy
('pg_publication'::regclass, 0, 0), -- no publication
('pg_publication_rel'::regclass, 0, 0), -- no publication relation
- ('pg_subscription'::regclass, 0, 0), -- no subscription
+ ('pg_sub'::regclass, 0, 0), -- no subscription
('pg_transform'::regclass, 0, 0) -- no transformation
)
SELECT ROW(pg_identify_object(objects.classid, objects.objid, objects.objsubid))
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out
index 6ea169d9ad..9f044f2376 100644
--- a/src/test/regress/expected/plpgsql.out
+++ b/src/test/regress/expected/plpgsql.out
@@ -4358,14 +4358,14 @@ end;
$$ language plpgsql;
-- "limit" is to prevent this from being inlined
create function sql_recurse(float8) returns float8 as
-$$ select recurse($1) limit 1; $$ language sql;
+$$ select recurse($1) limit 1; $$ LANGUAGE SQLTEST;
select recurse(10);
recurse
---------
0
(1 row)
-create function error1(text) returns text language sql as
+create function error1(text) returns text LANGUAGE SQLTEST as
$$ SELECT relname::text FROM pg_class c WHERE c.oid = $1::regclass $$;
create function error2(p_name_table text) returns text language plpgsql as $$
begin
@@ -4391,7 +4391,7 @@ drop function error1(text);
-- Test for proper handling of cast-expression caching
create function sql_to_date(integer) returns date as $$
select $1::text::date
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
create cast (integer as date) with function sql_to_date(integer) as assignment;
create function cast_invoker(integer) returns date as $$
begin
diff --git a/src/test/regress/expected/polymorphism.out b/src/test/regress/expected/polymorphism.out
index 772345584f..648132db4e 100644
--- a/src/test/regress/expected/polymorphism.out
+++ b/src/test/regress/expected/polymorphism.out
@@ -4,7 +4,7 @@
--
create function polyf(x anyelement) returns anyelement as $$
select x + 1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
int | num
-----+-----
@@ -23,7 +23,7 @@ CONTEXT: SQL function "polyf" during inlining
drop function polyf(x anyelement);
create function polyf(x anyelement) returns anyarray as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
int | num
---------+-----------
@@ -33,7 +33,7 @@ select polyf(42) as int, polyf(4.5) as num;
drop function polyf(x anyelement);
create function polyf(x anyarray) returns anyelement as $$
select x[1]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
int | num
-----+-----
@@ -45,7 +45,7 @@ ERROR: cannot determine element type of "anyarray" argument
drop function polyf(x anyarray);
create function polyf(x anyarray) returns anyarray as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
int | num
-------+-----------
@@ -59,12 +59,12 @@ drop function polyf(x anyarray);
-- fail, can't infer type:
create function polyf(x anyelement) returns anyrange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
create function polyf(x anyrange) returns anyarray as $$
select array[lower(x), upper(x)]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num;
int | num
---------+-----------
@@ -74,7 +74,7 @@ select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num;
drop function polyf(x anyrange);
create function polyf(x anycompatible, y anycompatible) returns anycompatiblearray as $$
select array[x, y]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(2, 4) as int, polyf(2, 4.5) as num;
int | num
-------+---------
@@ -84,7 +84,7 @@ select polyf(2, 4) as int, polyf(2, 4.5) as num;
drop function polyf(x anycompatible, y anycompatible);
create function polyf(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), 11, 2::smallint) as int, polyf(float8range(4.5, 7.8), 7.8, 11::real) as num;
int | num
--------------+------------------
@@ -99,7 +99,7 @@ HINT: No function matches the given name and argument types. You might need to
drop function polyf(x anycompatiblerange, y anycompatible, z anycompatible);
create function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), 11, 2::smallint) as int, polyf(multirange(float8range(4.5, 7.8)), 7.8, 11::real) as num;
int | num
--------------+------------------
@@ -115,12 +115,12 @@ drop function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible)
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblerange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function polyf(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), array[11]) as int, polyf(float8range(4.5, 7.8), array[7]) as num;
int | num
---------+-----------
@@ -131,12 +131,12 @@ drop function polyf(x anycompatiblerange, y anycompatiblearray);
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblemultirange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblemultirange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function polyf(x anycompatiblemultirange, y anycompatiblearray) returns anycompatiblemultirange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), array[11]) as int, polyf(multirange(float8range(4.5, 7.8)), array[7]) as num;
int | num
-----------+-------------
@@ -149,7 +149,7 @@ create function polyf(a anyelement, b anyarray,
OUT x anyarray, OUT y anycompatiblearray)
as $$
select a || b, array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x), y, pg_typeof(y)
from polyf(11, array[1, 2], 42, 34.5);
x | pg_typeof | y | pg_typeof
@@ -216,31 +216,31 @@ drop function polyf(a anyelement, b anyarray,
-- functions, i.e. tf arg1 and tf return type must match
-- polymorphic single arg transfn
CREATE FUNCTION stfp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- non-polymorphic single arg transfn
CREATE FUNCTION stfnp(int[]) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- dual polymorphic transfn
CREATE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- dual non-polymorphic transfn
CREATE FUNCTION tfnp(int[],int) RETURNS int[] AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- arg1 only polymorphic transfn
CREATE FUNCTION tf1p(anyarray,int) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- arg2 only polymorphic transfn
CREATE FUNCTION tf2p(int[],anyelement) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- multi-arg polymorphic
CREATE FUNCTION sum3(anyelement,anyelement,anyelement) returns anyelement AS
-'select $1+$2+$3' language sql strict;
+'select $1+$2+$3' LANGUAGE SQLTEST strict;
-- finalfn polymorphic
CREATE FUNCTION ffp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- finalfn non-polymorphic
CREATE FUNCTION ffnp(int[]) returns int[] as
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- Try to cover all the possible states:
--
-- Note: in Cases 1 & 2, we are trying to return P. Therefore, if the transfn
@@ -731,7 +731,7 @@ begin
return $1;
end$$ language plpgsql;
create function sql_if(bool, anyelement, anyelement) returns anyelement as $$
-select case when $1 then $2 else $3 end $$ language sql;
+select case when $1 then $2 else $3 end $$ LANGUAGE SQLTEST;
-- Note this would fail with integer overflow, never mind wrong bleat() output,
-- if the CASE expression were not successfully inlined
select f1, sql_if(f1 > 0, bleat(f1), bleat(f1 + 1)) from int4_tbl;
@@ -818,9 +818,9 @@ create aggregate build_group(int8, integer) (
);
-- check proper resolution of data types for polymorphic transfn/finalfn
create function first_el_transfn(anyarray, anyelement) returns anyarray as
-'select $1 || $2' language sql immutable;
+'select $1 || $2' LANGUAGE SQLTEST immutable;
create function first_el(anyarray) returns anyelement as
-'select $1[1]' language sql strict immutable;
+'select $1[1]' LANGUAGE SQLTEST strict immutable;
create aggregate first_el_agg_f8(float8) (
SFUNC = array_append,
STYPE = float8[],
@@ -901,7 +901,7 @@ ERROR: cannot accept a value of type anyrange
-- test variadic polymorphic functions
create function myleast(variadic anyarray) returns anyelement as $$
select min($1[i]) from generate_subscripts($1,1) g(i)
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select myleast(10, 1, 20, 33);
myleast
---------
@@ -948,7 +948,7 @@ select myleast(variadic array[]::int[]);
-- an example with some ordinary arguments too
create function concat(text, variadic anyarray) returns text as $$
select array_to_string($2, $1);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select concat('%', 1, 2, 3, 4, 5);
concat
-----------
@@ -977,7 +977,7 @@ drop function concat(text, anyarray);
-- mix variadic with anyelement
create function formarray(anyelement, variadic anyarray) returns anyarray as $$
select array_prepend($1, $2);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select formarray(1,2,3,4,5);
formarray
-------------
@@ -1065,7 +1065,7 @@ select pg_typeof(myleast(10, 1, 20, 33)); -- polymorphic input
-- test basic functionality
create function dfunc(a int = 1, int = 2) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
-------
@@ -1097,12 +1097,12 @@ drop function dfunc(int, int); -- ok
-- fail: defaults must be at end of argument list
create function dfunc(a int = 1, b int) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: input parameters after one with a default value must also have defaults
-- however, this should work:
create function dfunc(a int = 1, out sum int, b int = 2) as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
-------
@@ -1121,7 +1121,7 @@ drop function dfunc(int, int);
-- check implicit coercion
create function dfunc(a int DEFAULT 1.0, int DEFAULT '-1') returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
-------
@@ -1130,7 +1130,7 @@ select dfunc();
create function dfunc(a text DEFAULT 'Hello', b text DEFAULT 'World') returns text as $$
select $1 || ', ' || $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(); -- fail: which dfunc should be called? int or text
ERROR: function dfunc() is not unique
LINE 1: select dfunc();
@@ -1164,10 +1164,10 @@ drop function dfunc(int, int);
drop function dfunc(text, text);
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2, int = 3, int = 4) returns int as $$
select 4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- Now, dfunc(nargs = 2) and dfunc(nargs = 4) are ambiguous when called
-- with 0 to 2 arguments.
select dfunc(); -- fail
@@ -1202,12 +1202,12 @@ drop function dfunc(int, int, int, int);
-- default values are not allowed for output parameters
create function dfunc(out int = 20) returns int as $$
select 1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: only input parameters can have default values
-- polymorphic parameter test
create function dfunc(anyelement = 'World'::text) returns text as $$
select 'Hello, ' || $1::text;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
dfunc
--------------
@@ -1235,7 +1235,7 @@ select dfunc('City'::text);
drop function dfunc(anyelement);
-- check defaults for variadics
create function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- fail
ERROR: function dfunc() does not exist
LINE 1: select dfunc();
@@ -1254,7 +1254,7 @@ select dfunc(10,20);
(1 row)
create or replace function dfunc(a variadic int[] default array[]::int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- now ok
dfunc
-------
@@ -1275,7 +1275,7 @@ select dfunc(10,20);
-- can't remove the default once it exists
create or replace function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
ERROR: cannot remove parameter defaults from existing function
HINT: Use DROP FUNCTION dfunc(integer[]) first.
\df dfunc
@@ -1289,13 +1289,13 @@ drop function dfunc(a variadic int[]);
-- Ambiguity should be reported only if there's not a better match available
create function dfunc(int = 1, int = 2, int = 3) returns int as $$
select 3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(text) returns text as $$
select $1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- dfunc(narg=2) and dfunc(narg=3) are ambiguous
select dfunc(1); -- fail
ERROR: function dfunc(integer) is not unique
@@ -1318,7 +1318,7 @@ drop function dfunc(text);
create function dfunc(a int, b int, c int = 0, d int = 0)
returns table (a int, b int, c int, d int) as $$
select $1, $2, $3, $4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc(10,20,30)).*;
a | b | c | d
----+----+----+---
@@ -1394,7 +1394,7 @@ drop function dfunc(int, int, int, int);
create function dfunc(a varchar, b numeric, c date = current_date)
returns table (a varchar, b numeric, c date) as $$
select $1, $2, $3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc('Hello World', 20, '2009-07-25'::date)).*;
a | b | c
-------------+----+------------
@@ -1435,7 +1435,7 @@ drop function dfunc(varchar, numeric, date);
create function dfunc(a varchar = 'def a', out _a varchar, c numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc()).*;
_a | _c
-------+----
@@ -1488,27 +1488,27 @@ select * from dfunc(c := 100);
create or replace function dfunc(a varchar = 'def a', out _a varchar, x numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot change name of input parameter "c"
HINT: Use DROP FUNCTION dfunc(character varying,numeric) first.
create or replace function dfunc(a varchar = 'def a', out _a varchar, numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot change name of input parameter "c"
HINT: Use DROP FUNCTION dfunc(character varying,numeric) first.
drop function dfunc(varchar, numeric);
--fail, named parameters are not unique
-create function testpolym(a int, a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(a int, a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-create function testpolym(a int, inout a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
ERROR: parameter name "a" used more than once
-- valid
-create function testpolym(a int, out a int) returns int as $$ select $1;$$ language sql;
+create function testpolym(a int, out a int) returns int as $$ select $1;$$ LANGUAGE SQLTEST;
select testpolym(37);
testpolym
-----------
@@ -1516,7 +1516,7 @@ select testpolym(37);
(1 row)
drop function testpolym(int);
-create function testpolym(a int) returns table(a int) as $$ select $1;$$ language sql;
+create function testpolym(a int) returns table(a int) as $$ select $1;$$ LANGUAGE SQLTEST;
select * from testpolym(37);
a
----
@@ -1528,7 +1528,7 @@ drop function testpolym(int);
create function dfunc(a anyelement, b anyelement = null, flag bool = true)
returns anyelement as $$
select case when $3 then $1 else $2 end;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(1,2);
dfunc
-------
@@ -1749,7 +1749,7 @@ drop function dfunc(anyelement, anyelement, bool);
create function anyctest(anycompatible, anycompatible)
returns anycompatible as $$
select greatest($1, $2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
----+-----------
@@ -1777,7 +1777,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatible)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
---------+-----------
@@ -1799,7 +1799,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatiblearray)
returns anycompatiblearray as $$
select array[$1] || $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[12]) x;
x | pg_typeof
---------+-----------
@@ -1838,7 +1838,7 @@ drop function anyctest(anycompatible, anycompatiblearray);
create function anyctest(anycompatible, anycompatiblerange)
returns anycompatiblerange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, int4range(4,7)) x;
x | pg_typeof
-------+-----------
@@ -1867,7 +1867,7 @@ drop function anyctest(anycompatible, anycompatiblerange);
create function anyctest(anycompatiblerange, anycompatiblerange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(int4range(11,12), int4range(4,7)) x;
x | pg_typeof
----+-----------
@@ -1884,13 +1884,13 @@ drop function anyctest(anycompatiblerange, anycompatiblerange);
create function anyctest(anycompatible)
returns anycompatiblerange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function anyctest(anycompatible, anycompatiblemultirange)
returns anycompatiblemultirange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, multirange(int4range(4,7))) x;
x | pg_typeof
---------+----------------
@@ -1919,7 +1919,7 @@ drop function anyctest(anycompatible, anycompatiblemultirange);
create function anyctest(anycompatiblemultirange, anycompatiblemultirange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(int4range(4,7))) x;
x | pg_typeof
----+-----------
@@ -1936,13 +1936,13 @@ drop function anyctest(anycompatiblemultirange, anycompatiblemultirange);
create function anyctest(anycompatible)
returns anycompatiblemultirange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblemultirange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
create function anyctest(anycompatiblenonarray, anycompatiblenonarray)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
---------+-----------
@@ -1965,7 +1965,7 @@ create function anyctest(a anyelement, b anyarray,
c anycompatible, d anycompatible)
returns anycompatiblearray as $$
select array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[1, 2], 42, 34.5) x;
x | pg_typeof
-----------+-----------
@@ -1994,7 +1994,7 @@ drop function anyctest(a anyelement, b anyarray,
create function anyctest(variadic anycompatiblearray)
returns anycompatiblearray as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
x | pg_typeof
---------+-----------
diff --git a/src/test/regress/expected/portals.out b/src/test/regress/expected/portals.out
index dc0d2ef7dd..09c07bd9d4 100644
--- a/src/test/regress/expected/portals.out
+++ b/src/test/regress/expected/portals.out
@@ -779,7 +779,7 @@ BEGIN;
CREATE FUNCTION declares_cursor(text)
RETURNS void
AS 'DECLARE c CURSOR FOR SELECT stringu1 FROM tenk1 WHERE stringu1 LIKE $1;'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT declares_cursor('AB%');
declares_cursor
-----------------
@@ -814,9 +814,9 @@ ROLLBACK;
--
create temp table tt1(f1 int);
create function count_tt1_v() returns int8 as
-'select count(*) from tt1' language sql volatile;
+'select count(*) from tt1' LANGUAGE SQLTEST volatile;
create function count_tt1_s() returns int8 as
-'select count(*) from tt1' language sql stable;
+'select count(*) from tt1' LANGUAGE SQLTEST stable;
begin;
insert into tt1 values(1);
declare c1 cursor for select count_tt1_v(), count_tt1_s();
@@ -1359,7 +1359,7 @@ DROP TABLE cursor;
-- per bug report in 8336843.9833.1399385291498.JavaMail.root@quick
begin;
create function nochange(int) returns int
- as 'select $1 limit 1' language sql stable;
+ as 'select $1 limit 1' LANGUAGE SQLTEST stable;
declare c cursor for select * from int8_tbl limit nochange(3);
fetch all from c;
q1 | q2
diff --git a/src/test/regress/expected/privileges.out b/src/test/regress/expected/privileges.out
index 46a69fc0dc..83e82839a6 100644
--- a/src/test/regress/expected/privileges.out
+++ b/src/test/regress/expected/privileges.out
@@ -824,18 +824,18 @@ END;
-- privileges on functions, languages
-- switch to superuser
\c -
-REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user1; -- ok
+REVOKE ALL PRIVILEGES ON LANGUAGE sqltest FROM PUBLIC;
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user1; -- ok
GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
ERROR: language "c" is not trusted
DETAIL: GRANT and REVOKE are not allowed on untrusted languages, because only superusers can use untrusted languages.
SET SESSION AUTHORIZATION regress_priv_user1;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user2; -- fail
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user2; -- fail
WARNING: no privileges were granted for "sql"
-CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql;
-CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest;
+CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE priv_testagg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sql;
+CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sqltest;
REVOKE ALL ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) TO regress_priv_user2;
REVOKE ALL ON FUNCTION priv_testproc1(int) FROM PUBLIC; -- fail, not a function
@@ -855,7 +855,7 @@ GRANT ALL PRIVILEGES ON FUNCTION priv_testagg1(int) TO regress_priv_user4;
GRANT ALL PRIVILEGES ON PROCEDURE priv_testproc1(int) TO regress_priv_user4;
CREATE FUNCTION priv_testfunc4(boolean) RETURNS text
AS 'select col1 from atest2 where col2 = $1;'
- LANGUAGE sql SECURITY DEFINER;
+ LANGUAGE sqltest SECURITY DEFINER;
GRANT EXECUTE ON FUNCTION priv_testfunc4(boolean) TO regress_priv_user3;
SET SESSION AUTHORIZATION regress_priv_user2;
SELECT priv_testfunc1(5), priv_testfunc2(5); -- ok
@@ -864,8 +864,8 @@ SELECT priv_testfunc1(5), priv_testfunc2(5); -- ok
10 | 15
(1 row)
-CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail
-ERROR: permission denied for language sql
+CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest; -- fail
+ERROR: permission denied for LANGUAGE SQLTEST
SELECT priv_testagg1(x) FROM (VALUES (1), (2), (3)) _(x); -- ok
priv_testagg1
---------------
@@ -911,7 +911,7 @@ ERROR: must be owner of procedure priv_testproc1
\c -
DROP FUNCTION priv_testfunc1(int); -- ok
-- restore to sanity
-GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
+GRANT ALL PRIVILEGES ON LANGUAGE sqltest TO PUBLIC;
-- verify privilege checks on array-element coercions
BEGIN;
SELECT '{1}'::int4[]::int8[];
@@ -953,14 +953,14 @@ ERROR: permission denied for type priv_testdomain1
CREATE DOMAIN priv_testdomain2a AS priv_testdomain1;
ERROR: permission denied for type priv_testdomain1
CREATE DOMAIN priv_testdomain3a AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3a) WITH FUNCTION castfunc(int);
ERROR: permission denied for type priv_testdomain1
DROP FUNCTION castfunc(int) CASCADE;
DROP DOMAIN priv_testdomain3a;
-CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
ERROR: permission denied for type priv_testdomain1
-CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
ERROR: permission denied for type priv_testdomain1
CREATE OPERATOR !+! (PROCEDURE = int4pl, LEFTARG = priv_testdomain1, RIGHTARG = priv_testdomain1);
ERROR: permission denied for type priv_testdomain1
@@ -991,11 +991,11 @@ SET SESSION AUTHORIZATION regress_priv_user2;
CREATE AGGREGATE priv_testagg1b(priv_testdomain1) (sfunc = int4_sum, stype = bigint);
CREATE DOMAIN priv_testdomain2b AS priv_testdomain1;
CREATE DOMAIN priv_testdomain3b AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3b) WITH FUNCTION castfunc(int);
WARNING: cast will be ignored because the source data type is a domain
-CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
-CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
CREATE OPERATOR !! (PROCEDURE = priv_testfunc5b, RIGHTARG = priv_testdomain1);
CREATE TABLE test5b (a int, b priv_testdomain1);
CREATE TABLE test6b OF priv_testtype1;
@@ -1417,9 +1417,9 @@ SELECT has_table_privilege('regress_priv_user1', 'atest4', 'SELECT WITH GRANT OP
\c -
CREATE ROLE regress_sro_user;
SET SESSION AUTHORIZATION regress_sro_user;
-CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sql AS
+CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sqltest AS
'GRANT regress_priv_group2 TO regress_sro_user';
-CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'DECLARE c CURSOR WITH HOLD FOR SELECT unwanted_grant(); SELECT true';
-- REFRESH of this MV will queue a GRANT at end of transaction
CREATE MATERIALIZED VIEW sro_mv AS SELECT mv_action() WITH NO DATA;
@@ -1438,7 +1438,7 @@ CREATE FUNCTION sro_trojan() RETURNS trigger LANGUAGE plpgsql AS
CREATE CONSTRAINT TRIGGER t AFTER INSERT ON sro_trojan_table
INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE sro_trojan();
-- Now, REFRESH will issue such an INSERT, queueing the GRANT
-CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'INSERT INTO sro_trojan_table DEFAULT VALUES; SELECT true';
REFRESH MATERIALIZED VIEW sro_mv;
ERROR: cannot fire deferred trigger within security-restricted operation
@@ -1457,7 +1457,7 @@ DROP OWNED BY regress_sro_user;
DROP ROLE regress_sro_user;
-- Admin options
SET SESSION AUTHORIZATION regress_priv_user4;
-CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: had ADMIN OPTION
SET ROLE regress_priv_group2;
@@ -1479,7 +1479,7 @@ ERROR: must have admin option on role "regress_priv_group2"
SET SESSION AUTHORIZATION regress_priv_group2;
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: a role can self-admin
NOTICE: role "regress_priv_user5" is already a member of role "regress_priv_group2"
-CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
SELECT dogrant_fails(); -- fails: no self-admin in SECURITY DEFINER
ERROR: must have admin option on role "regress_priv_group2"
@@ -1890,9 +1890,9 @@ SELECT has_schema_privilege('regress_priv_user2', 'testns5', 'CREATE'); -- no
(1 row)
SET ROLE regress_priv_user1;
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- no
has_function_privilege
------------------------
@@ -1913,11 +1913,11 @@ SELECT has_function_privilege('regress_priv_user2', 'testns.bar()', 'EXECUTE');
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT EXECUTE ON ROUTINES to public;
DROP FUNCTION testns.foo();
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
DROP AGGREGATE testns.agg1(int);
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
DROP PROCEDURE testns.bar();
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- yes
has_function_privilege
------------------------
@@ -2016,9 +2016,9 @@ SELECT has_table_privilege('regress_priv_user1', 'testns.t2', 'SELECT'); -- fals
f
(1 row)
-CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE testns.priv_testagg(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sql;
+CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user1', 'testns.priv_testfunc(int)', 'EXECUTE'); -- true by default
has_function_privilege
------------------------
@@ -2203,7 +2203,7 @@ SELECT lo_unlink(oid) FROM pg_largeobject_metadata WHERE oid >= 1000 AND oid < 3
DROP GROUP regress_priv_group1;
DROP GROUP regress_priv_group2;
-- these are needed to clean up permissions
-REVOKE USAGE ON LANGUAGE sql FROM regress_priv_user1;
+REVOKE USAGE ON LANGUAGE sqltest FROM regress_priv_user1;
DROP OWNED BY regress_priv_user1;
DROP USER regress_priv_user1;
DROP USER regress_priv_user2;
diff --git a/src/test/regress/expected/rangefuncs.out b/src/test/regress/expected/rangefuncs.out
index 5bbd5f6c0b..3621a29cf1 100644
--- a/src/test/regress/expected/rangefuncs.out
+++ b/src/test/regress/expected/rangefuncs.out
@@ -2,7 +2,7 @@ CREATE TABLE rngfunc2(rngfuncid int, f2 int);
INSERT INTO rngfunc2 VALUES(1, 11);
INSERT INTO rngfunc2 VALUES(2, 22);
INSERT INTO rngfunc2 VALUES(1, 111);
-CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQL;
+CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQLTEST;
-- function with ORDINALITY
select * from rngfunct(1) with ordinality as z(a,b,ord);
a | b | ord
@@ -340,7 +340,7 @@ INSERT INTO rngfunc VALUES(1,1,'Joe');
INSERT INTO rngfunc VALUES(1,2,'Ed');
INSERT INTO rngfunc VALUES(2,1,'Mary');
-- sql, proretset = f, prorettype = b
-CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc1(1) AS t1;
t1
----
@@ -370,7 +370,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc2(1) AS t1;
t1
----
@@ -404,7 +404,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc3(1) AS t1;
t1
-----
@@ -438,7 +438,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = c
-CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc4(1) AS t1;
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -468,7 +468,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = c
-CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc5(1) AS t1;
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -502,7 +502,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = record
-CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc6(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -535,7 +535,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = record
-CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc7(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
rngfuncid | rngfuncsubid | rngfuncname
-----------+--------------+-------------
@@ -697,7 +697,7 @@ DROP TABLE rngfunc;
CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq1;
CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq2;
CREATE TYPE rngfunc_rescan_t AS (i integer, s bigint);
-CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQL;
+CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQLTEST;
-- plpgsql functions use materialize mode
CREATE FUNCTION rngfunc_mat(int,int) RETURNS setof rngfunc_rescan_t AS 'begin for i in $1..$2 loop return next (i, nextval(''rngfunc_rescan_seq2'')); end loop; end;' LANGUAGE plpgsql;
--invokes ExecReScanFunctionScan - all these cases should materialize the function only once
@@ -1424,7 +1424,7 @@ DROP SEQUENCE rngfunc_rescan_seq2;
-- Test cases involving OUT parameters
--
CREATE FUNCTION rngfunc(in f1 int, out f2 int)
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
SELECT rngfunc(42);
rngfunc
---------
@@ -1445,22 +1445,22 @@ SELECT * FROM rngfunc(42) AS p(x);
-- explicit spec of return type is OK
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
-- error, wrong result type
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS float
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
ERROR: function result type must be integer because of OUT parameters
-- with multiple OUT params you must get a RECORD result
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
ERROR: function result type must be record because of OUT parameters
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text)
RETURNS record
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
ERROR: cannot change return type of existing function
HINT: Use DROP FUNCTION rngfunc(integer) first.
CREATE OR REPLACE FUNCTION rngfuncr(in f1 int, out f2 int, out text)
-AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncr(f1) FROM int4_tbl;
f1 | rngfuncr
-------------+----------------------------
@@ -1484,7 +1484,7 @@ SELECT * FROM rngfuncr(42) AS p(a,b);
(1 row)
CREATE OR REPLACE FUNCTION rngfuncb(in f1 int, inout f2 int, out text)
-AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncb(f1, f1/2) FROM int4_tbl;
f1 | rngfuncb
-------------+----------------------------
@@ -1515,7 +1515,7 @@ DROP FUNCTION rngfuncb(in f1 int, inout f2 int);
-- For my next trick, polymorphic OUT parameters
--
CREATE FUNCTION dup (f1 anyelement, f2 out anyelement, f3 out anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
dup
----------------
@@ -1538,13 +1538,13 @@ SELECT * FROM dup('xyz'::text);
-- fails, as we are attempting to rename first argument
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
ERROR: cannot change name of input parameter "f1"
HINT: Use DROP FUNCTION dup(anyelement) first.
DROP FUNCTION dup(anyelement);
-- equivalent behavior, though different name exposed for input arg
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
dup
----------------
@@ -1554,11 +1554,11 @@ SELECT dup(22);
DROP FUNCTION dup(anyelement);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 int, out f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
ERROR: cannot determine result data type
DETAIL: A result of type anyelement requires at least one input of type anyelement, anyarray, anynonarray, anyenum, anyrange, or anymultirange.
CREATE FUNCTION dup (f1 anycompatible, f2 anycompatiblearray, f3 out anycompatible, f4 out anycompatiblearray)
-AS 'select $1, $2' LANGUAGE sql;
+AS 'select $1, $2' LANGUAGE sqltest;
SELECT dup(22, array[44]);
dup
-----------
@@ -1585,7 +1585,7 @@ SELECT *, pg_typeof(f3), pg_typeof(f4) FROM dup(22, array[44::bigint]);
DROP FUNCTION dup(f1 anycompatible, f2 anycompatiblearray);
CREATE FUNCTION dup (f1 anycompatiblerange, f2 out anycompatible, f3 out anycompatiblearray, f4 out anycompatiblerange)
-AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sql;
+AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sqltest;
SELECT dup(int4range(4,7));
dup
---------------------
@@ -1607,7 +1607,7 @@ SELECT dup(textrange('aaa', 'bbb'));
DROP FUNCTION dup(f1 anycompatiblerange);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 anyarray, out f2 anycompatible, out f3 anycompatiblearray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatible requires at least one input of type anycompatible, anycompatiblearray, anycompatiblenonarray, or anycompatiblerange.
--
@@ -1615,7 +1615,7 @@ DETAIL: A result of type anycompatible requires at least one input of type anyc
--
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a int)
-AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sql;
+AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc();
a
---
@@ -1631,7 +1631,7 @@ CREATE OR REPLACE FUNCTION rngfunc(int)
RETURNS TABLE(a int, b int)
AS $$ SELECT a, b
FROM generate_series(1,$1) a(a),
- generate_series(1,$1) b(b) $$ LANGUAGE sql;
+ generate_series(1,$1) b(b) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc(3);
a | b
---+---
@@ -1650,7 +1650,7 @@ DROP FUNCTION rngfunc(int);
-- case that causes change of typmod knowledge during inlining
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a varchar(5))
-AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sql STABLE;
+AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sqltest STABLE;
SELECT * FROM rngfunc() GROUP BY 1;
a
-------
@@ -1664,7 +1664,7 @@ DROP FUNCTION rngfunc();
create temp table tt(f1 serial, data text);
create function insert_tt(text) returns int as
$$ insert into tt(data) values($1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('foo');
insert_tt
-----------
@@ -1687,7 +1687,7 @@ select * from tt;
-- insert will execute to completion even if function needs just 1 row
create or replace function insert_tt(text) returns int as
$$ insert into tt(data) values($1),($1||$1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('fool');
insert_tt
-----------
@@ -1706,7 +1706,7 @@ select * from tt;
-- setof does what's expected
create or replace function insert_tt2(text,text) returns setof int as
$$ insert into tt(data) values($1),($2) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt2('foolish','barrish');
insert_tt2
------------
@@ -1832,7 +1832,7 @@ select * from tt_log;
-- test case for a whole-row-variable bug
create function rngfunc1(n integer, out a text, out b text)
returns setof record
- language sql
+ LANGUAGE SQLTEST
as $$ select 'foo ' || i, 'bar ' || i from generate_series(1,$1) i $$;
set work_mem='64kB';
select t.a, t, t.a from rngfunc1(10000) t limit 1;
@@ -1854,7 +1854,7 @@ drop function rngfunc1(n integer);
-- the actual record type ...
create function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql strict immutable;
+$$ LANGUAGE SQLTEST strict immutable;
select array_to_set(array['one', 'two']);
array_to_set
--------------
@@ -1899,7 +1899,7 @@ explain (verbose, costs off)
-- but without, it can be:
create or replace function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select array_to_set(array['one', 'two']);
array_to_set
--------------
@@ -1937,7 +1937,7 @@ explain (verbose, costs off)
create temp table rngfunc(f1 int8, f2 int8);
create function testrngfunc() returns record as $$
insert into rngfunc values (1,2) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
testrngfunc
-------------
@@ -1957,7 +1957,7 @@ LINE 1: select * from testrngfunc();
drop function testrngfunc();
create function testrngfunc() returns setof record as $$
insert into rngfunc values (1,2), (3,4) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
testrngfunc
-------------
@@ -1981,7 +1981,7 @@ drop function testrngfunc();
create type rngfunc_type as (f1 numeric(35,6), f2 numeric(35,2));
create function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2013,7 +2013,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2046,7 +2046,7 @@ select * from testrngfunc();
drop function testrngfunc();
create function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2078,7 +2078,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2111,7 +2111,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 1, 2 union select 3, 4 order by 1;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
QUERY PLAN
@@ -2177,7 +2177,7 @@ insert into users values ('id2',2,'email2',true,12,true);
alter table users drop column todrop;
create or replace function get_first_user() returns users as
$$ SELECT * FROM users ORDER BY userid LIMIT 1; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_first_user();
get_first_user
-------------------
@@ -2192,7 +2192,7 @@ SELECT * FROM get_first_user();
create or replace function get_users() returns setof users as
$$ SELECT * FROM users ORDER BY userid; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_users();
get_users
---------------------
@@ -2263,7 +2263,7 @@ drop table users;
-- check behavior with type coercion required for a set-op
create or replace function rngfuncbar() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar ; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select rngfuncbar();
rngfuncbar
------------
@@ -2294,7 +2294,7 @@ explain (verbose, costs off) select * from rngfuncbar();
drop function rngfuncbar();
-- check handling of a SQL function with multiple OUT params (bug #5777)
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1) $$ language sql;
+$$ select (1, 2.1) $$ LANGUAGE SQLTEST;
select * from rngfuncbar();
column1 | column2
---------+---------
@@ -2302,12 +2302,12 @@ select * from rngfuncbar();
(1 row)
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2) $$ language sql;
+$$ select (1, 2) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
ERROR: function return row and query-specified return row do not match
DETAIL: Returned type integer at ordinal position 2, but query expects numeric.
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1, 3) $$ language sql;
+$$ select (1, 2.1, 3) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
ERROR: function return row and query-specified return row do not match
DETAIL: Returned row contains 3 attributes, but query expects 2.
@@ -2315,7 +2315,7 @@ drop function rngfuncbar();
-- check whole-row-Var handling in nested lateral functions (bug #11703)
create function extractq2(t int8_tbl) returns int8 as $$
select t.q2
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2(int8_tbl) f(x);
QUERY PLAN
@@ -2341,7 +2341,7 @@ select x from int8_tbl, extractq2(int8_tbl) f(x);
create function extractq2_2(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t) offset 0
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2(int8_tbl) f(x);
QUERY PLAN
@@ -2367,7 +2367,7 @@ select x from int8_tbl, extractq2_2(int8_tbl) f(x);
-- without the "offset 0", this function gets optimized quite differently
create function extractq2_2_opt(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t)
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x);
QUERY PLAN
diff --git a/src/test/regress/expected/rangetypes.out b/src/test/regress/expected/rangetypes.out
index 05b882fde9..fa66386ed6 100644
--- a/src/test/regress/expected/rangetypes.out
+++ b/src/test/regress/expected/rangetypes.out
@@ -1539,7 +1539,7 @@ drop type textrange2;
-- Test polymorphic type system
--
create function anyarray_anyrange_func(a anyarray, r anyrange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anyrange_func(ARRAY[1,2], int4range(10,20));
anyarray_anyrange_func
------------------------
@@ -1555,16 +1555,16 @@ HINT: No function matches the given name and argument types. You might need to
drop function anyarray_anyrange_func(anyarray, anyrange);
-- should fail
create function bogus_func(anyelement)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
-- should fail
create function bogus_func(int)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
create function range_add_bounds(anyrange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4range(1, 17));
range_add_bounds
------------------
@@ -1579,7 +1579,7 @@ select range_add_bounds(numrange(1.0001, 123.123));
create function rangetypes_sql(q anyrange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select rangetypes_sql(int4range(1,10), ARRAY[2,20]);
rangetypes_sql
----------------
@@ -1592,7 +1592,7 @@ LINE 1: select rangetypes_sql(numrange(1,10), ARRAY[2,20]);
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
create function anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatiblerange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], int4range(10,20));
anycompatiblearray_anycompatiblerange_func
--------------------------------------------
@@ -1614,7 +1614,7 @@ HINT: No function matches the given name and argument types. You might need to
drop function anycompatiblearray_anycompatiblerange_func(anycompatiblearray, anycompatiblerange);
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anycompatiblerange requires at least one input of type anycompatiblerange or anycompatiblemultirange.
--
@@ -1696,7 +1696,7 @@ reset enable_sort;
--
-- infer anyrange from anyrange
create function outparam_succeed(i anyrange, out r anyrange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed(int4range(1,2));
r | t
-------+-----
@@ -1705,7 +1705,7 @@ select * from outparam_succeed(int4range(1,2));
create function outparam2_succeed(r anyrange, out lu anyarray, out ul anyarray)
as $$ select array[lower($1), upper($1)], array[upper($1), lower($1)] $$
- language sql;
+ LANGUAGE SQLTEST;
select * from outparam2_succeed(int4range(1,11));
lu | ul
--------+--------
@@ -1714,7 +1714,7 @@ select * from outparam2_succeed(int4range(1,11));
-- infer anyarray from anyrange
create function outparam_succeed2(i anyrange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed2(int4range(int4range(1,2)));
r | t
-----+-----
@@ -1723,7 +1723,7 @@ select * from outparam_succeed2(int4range(int4range(1,2)));
-- infer anyelement from anyrange
create function inoutparam_succeed(out i anyelement, inout r anyrange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from inoutparam_succeed(int4range(1,2));
i | r
---+-------
@@ -1733,7 +1733,7 @@ select * from inoutparam_succeed(int4range(1,2));
create function table_succeed(r anyrange)
returns table(l anyelement, u anyelement)
as $$ select lower($1), upper($1) $$
- language sql;
+ LANGUAGE SQLTEST;
select * from table_succeed(int4range(1,11));
l | u
---+----
@@ -1742,16 +1742,16 @@ select * from table_succeed(int4range(1,11));
-- should fail
create function outparam_fail(i anyelement, out r anyrange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
--should fail
create function inoutparam_fail(inout i anyelement, out r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
--should fail
create function table_fail(i anyelement) returns table(i anyelement, r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
ERROR: cannot determine result data type
DETAIL: A result of type anyrange requires at least one input of type anyrange or anymultirange.
diff --git a/src/test/regress/expected/rowtypes.out b/src/test/regress/expected/rowtypes.out
index 0e71baf8fb..4b187582b2 100644
--- a/src/test/regress/expected/rowtypes.out
+++ b/src/test/regress/expected/rowtypes.out
@@ -841,10 +841,10 @@ CREATE TYPE price_key AS (
);
CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
insert into price values (1,false,42), (10,false,100), (11,true,17.99);
UPDATE price
SET active = true, price = input_prices.price
@@ -866,20 +866,20 @@ rollback;
create temp table compos (f1 int, f2 text);
create function fcompos1(v compos) returns void as $$
insert into compos values (v); -- fail
-$$ language sql;
+$$ LANGUAGE SQLTEST;
ERROR: column "f1" is of type integer but expression is of type compos
LINE 2: insert into compos values (v); -- fail
^
HINT: You will need to rewrite or cast the expression.
create function fcompos1(v compos) returns void as $$
insert into compos values (v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos2(v compos) returns void as $$
select fcompos1(v);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos3(v compos) returns void as $$
select fcompos1(fcompos3.v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select fcompos1(row(1,'one'));
fcompos1
----------
@@ -968,7 +968,7 @@ select last(f) from fullname f;
Blow
(1 row)
-create function longname(fullname) returns text language sql
+create function longname(fullname) returns text LANGUAGE SQLTEST
as $$select $1.first || ' ' || $1.last$$;
select f.longname from fullname f;
longname
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index b632d9f2ea..5236431e43 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -764,7 +764,7 @@ create view rtest_vview4 as select X.a, X.b, count(Y.a) as refcount
group by X.a, X.b;
create function rtest_viewfunc1(int4) returns int4 as
'select count(*)::int4 from rtest_view2 where a = $1'
- language sql;
+ LANGUAGE SQLTEST;
create view rtest_vview5 as select a, b, rtest_viewfunc1(a) as refcount
from rtest_view1;
insert into rtest_view1 values (1, 'item 1', 't');
@@ -1654,7 +1654,7 @@ UNION ALL
l.provider,
l.label
FROM (pg_shseclabel l
- JOIN pg_subscription s ON (((l.classoid = s.tableoid) AND (l.objoid = s.oid))))
+ JOIN pg_sub s ON (((l.classoid = s.tableoid) AND (l.objoid = s.oid))))
UNION ALL
SELECT l.objoid,
l.classoid,
@@ -2064,17 +2064,17 @@ pg_stat_ssl| SELECT s.pid,
s.ssl_issuer_dn AS issuer_dn
FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, ssl_client_dn, ssl_client_serial, ssl_issuer_dn, gss_auth, gss_princ, gss_enc, leader_pid)
WHERE (s.client_port IS NOT NULL);
-pg_stat_subscription| SELECT su.oid AS subid,
+pg_stat_sub| SELECT su.oid AS subid,
su.subname,
st.pid,
st.relid,
st.received_lsn,
st.last_msg_send_time,
st.last_msg_receipt_time,
- st.latest_end_lsn,
+ st.latest_end_location,
st.latest_end_time
- FROM (pg_subscription su
- LEFT JOIN pg_stat_get_subscription(NULL::oid) st(subid, relid, pid, received_lsn, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time) ON ((st.subid = su.oid)));
+ FROM (pg_sub su
+ LEFT JOIN pg_stat_get_sub(NULL::oid) st(subid, relid, pid, received_lsn, last_msg_send_time, last_msg_receipt_time, latest_end_location, latest_end_time) ON ((st.subid = su.oid)));
pg_stat_sys_indexes| SELECT pg_stat_all_indexes.relid,
pg_stat_all_indexes.indexrelid,
pg_stat_all_indexes.schemaname,
@@ -2169,13 +2169,13 @@ pg_stat_wal_receiver| SELECT s.pid,
s.received_tli,
s.last_msg_send_time,
s.last_msg_receipt_time,
- s.latest_end_lsn,
+ s.latest_end_location,
s.latest_end_time,
s.slot_name,
s.sender_host,
s.sender_port,
s.conninfo
- FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_lsn, latest_end_time, slot_name, sender_host, sender_port, conninfo)
+ FROM pg_stat_get_wal_receiver() s(pid, status, receive_start_lsn, receive_start_tli, written_lsn, flushed_lsn, received_tli, last_msg_send_time, last_msg_receipt_time, latest_end_location, latest_end_time, slot_name, sender_host, sender_port, conninfo)
WHERE (s.pid IS NOT NULL);
pg_stat_xact_all_tables| SELECT c.oid AS relid,
n.nspname AS schemaname,
@@ -3435,7 +3435,7 @@ drop table hat_data;
-- Note that the function is kept around to stress pg_dump.
CREATE FUNCTION func_with_set_params() RETURNS integer
AS 'select 1;'
- LANGUAGE SQL
+ LANGUAGE SQLTEST
SET search_path TO PG_CATALOG
SET extra_float_digits TO 2
SET work_mem TO '4MB'
@@ -3447,7 +3447,7 @@ SELECT pg_get_functiondef('func_with_set_params()'::regprocedure);
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION public.func_with_set_params() +
RETURNS integer +
- LANGUAGE sql +
+ LANGUAGE sqltest +
IMMUTABLE STRICT +
SET search_path TO 'pg_catalog' +
SET extra_float_digits TO '2' +
diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out
index d9ce961be2..a1c612b5bd 100644
--- a/src/test/regress/expected/sanity_check.out
+++ b/src/test/regress/expected/sanity_check.out
@@ -151,8 +151,8 @@ pg_shseclabel|t
pg_statistic|t
pg_statistic_ext|t
pg_statistic_ext_data|t
-pg_subscription|t
-pg_subscription_rel|t
+pg_sub|t
+pg_sub_rel|t
pg_tablespace|t
pg_transform|t
pg_trigger|t
diff --git a/src/test/regress/expected/select.out b/src/test/regress/expected/select.out
index c441049f41..494911ffb6 100644
--- a/src/test/regress/expected/select.out
+++ b/src/test/regress/expected/select.out
@@ -915,7 +915,7 @@ SELECT 1 AS x ORDER BY x;
-- But ORDER BY on a set-valued expression does
create function sillysrf(int) returns setof int as
- 'values (1),(10),(2),($1)' language sql immutable;
+ 'values (1),(10),(2),($1)' LANGUAGE SQLTEST immutable;
select sillysrf(42);
sillysrf
----------
diff --git a/src/test/regress/expected/select_into.out b/src/test/regress/expected/select_into.out
index 43b8209d22..34e9503367 100644
--- a/src/test/regress/expected/select_into.out
+++ b/src/test/regress/expected/select_into.out
@@ -133,7 +133,7 @@ DROP TABLE ctas_nodata_4;
CREATE FUNCTION make_table() RETURNS VOID
AS $$
CREATE TABLE created_table AS SELECT * FROM int8_tbl;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
SELECT make_table();
make_table
------------
diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out
index 9b0c418db7..cf56b27664 100644
--- a/src/test/regress/expected/select_parallel.out
+++ b/src/test/regress/expected/select_parallel.out
@@ -124,7 +124,7 @@ reset enable_parallel_append;
-- Parallel Append that runs serially
create function sp_test_func() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select sp_test_func() order by 1;
sp_test_func
--------------
diff --git a/src/test/regress/expected/subscription.out b/src/test/regress/expected/subscription.out
index 2fa9bce66a..54ab1efd06 100644
--- a/src/test/regress/expected/subscription.out
+++ b/src/test/regress/expected/subscription.out
@@ -31,7 +31,7 @@ ERROR: publication name "foo" used more than once
CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false);
WARNING: tables were not subscribed, you will have to run ALTER SUBSCRIPTION ... REFRESH PUBLICATION to subscribe the tables
COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription';
-SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
+SELECT obj_description(s.oid, 'pg_sub') FROM pg_sub s;
obj_description
-------------------
test subscription
diff --git a/src/test/regress/expected/subselect.out b/src/test/regress/expected/subselect.out
index d5532d0ccc..ec73a50e30 100644
--- a/src/test/regress/expected/subselect.out
+++ b/src/test/regress/expected/subselect.out
@@ -811,7 +811,7 @@ HINT: No operator matches the given name and argument types. You might need to
begin;
-- make an operator to allow it to succeed
create function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2';
create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text);
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
@@ -833,7 +833,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function results in unusual number of hash clauses,
-- which we can still cope with
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2 and $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2 and $1::text = $2';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
QUERY PLAN
@@ -854,7 +854,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function causes LHS and RHS to be switched,
-- which we can't cope with, so hashing should be abandoned
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $2 = $1::text';
+LANGUAGE SQLTEST as 'select $2 = $1::text';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
QUERY PLAN
diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/temp.out
index a5b3ed34a3..1033b844c6 100644
--- a/src/test/regress/expected/temp.out
+++ b/src/test/regress/expected/temp.out
@@ -149,9 +149,9 @@ insert into public.whereami values ('public');
create temp table whereami (f1 text);
insert into whereami values ('temp');
create function public.whoami() returns text
- as $$select 'public'::text$$ language sql;
+ as $$select 'public'::text$$ LANGUAGE SQLTEST;
create function pg_temp.whoami() returns text
- as $$select 'temp'::text$$ language sql;
+ as $$select 'temp'::text$$ LANGUAGE SQLTEST;
-- default should have pg_temp implicitly first, but only for tables
select * from whereami;
f1
@@ -326,12 +326,12 @@ drop table temp_inh_oncommit_test;
-- Function creation
begin;
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
prepare transaction 'twophase_func';
ERROR: cannot PREPARE a transaction that has operated on temporary objects
-- Function drop
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
begin;
drop function pg_temp.twophase_func();
prepare transaction 'twophase_func';
diff --git a/src/test/regress/expected/transactions.out b/src/test/regress/expected/transactions.out
index 1b03310029..68153b45d3 100644
--- a/src/test/regress/expected/transactions.out
+++ b/src/test/regress/expected/transactions.out
@@ -472,7 +472,7 @@ select * from xacttest;
777 | 777.777
(5 rows)
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' stable;
begin;
update xacttest set a = max_xacttest() + 10 where a > 0;
@@ -488,7 +488,7 @@ select * from xacttest;
rollback;
-- But a volatile function can see the partial results of the calling query
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' volatile;
begin;
update xacttest set a = max_xacttest() + 10 where a > 0;
diff --git a/src/test/regress/expected/typed_table.out b/src/test/regress/expected/typed_table.out
index 2e47ecbcf5..d70baad15d 100644
--- a/src/test/regress/expected/typed_table.out
+++ b/src/test/regress/expected/typed_table.out
@@ -18,7 +18,7 @@ SELECT * FROM persons;
Typed table of type: person_type
CREATE FUNCTION get_all_persons() RETURNS SETOF person_type
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT * FROM persons;
$$;
@@ -95,7 +95,7 @@ DROP TABLE stuff;
CREATE TYPE person_type AS (id int, name text);
CREATE TABLE persons OF person_type;
INSERT INTO persons VALUES (1, 'test');
-CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$;
+CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQLTEST AS $$ SELECT length($1.name) $$;
SELECT id, namelen(persons) FROM persons;
id | namelen
----+---------
diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out
index 24905332b1..0380b393b7 100644
--- a/src/test/regress/expected/updatable_views.out
+++ b/src/test/regress/expected/updatable_views.out
@@ -944,7 +944,7 @@ CREATE TABLE base_tbl (a int PRIMARY KEY, b text DEFAULT 'Unspecified');
INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i);
CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl;
CREATE FUNCTION rw_view1_aa(x rw_view1)
- RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql;
+ RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sqltest;
UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2
RETURNING rw_view1_aa(v), v.bb;
rw_view1_aa | bb
diff --git a/src/test/regress/expected/vacuum.out b/src/test/regress/expected/vacuum.out
index 90cea6caa8..fcccba48a0 100644
--- a/src/test/regress/expected/vacuum.out
+++ b/src/test/regress/expected/vacuum.out
@@ -61,9 +61,9 @@ VACUUM (ANALYZE, FULL) vactst;
CREATE TABLE vaccluster (i INT PRIMARY KEY);
ALTER TABLE vaccluster CLUSTER ON vaccluster_pkey;
CLUSTER vaccluster;
-CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL
+CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQLTEST
AS 'ANALYZE pg_am';
-CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL
+CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQLTEST
AS 'SELECT $1 FROM do_analyze()';
CREATE INDEX ON vaccluster(wrap_do_analyze(i));
INSERT INTO vaccluster VALUES (1), (2);
diff --git a/src/test/regress/expected/window.out b/src/test/regress/expected/window.out
index 19e2ac518a..c3a344c780 100644
--- a/src/test/regress/expected/window.out
+++ b/src/test/regress/expected/window.out
@@ -3318,13 +3318,13 @@ SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four
-- intentionally not true inverses)
CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE AGGREGATE logging_agg_nonstrict (anyelement)
(
stype = text,
@@ -3345,13 +3345,13 @@ CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement)
);
CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '*' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '+' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE AGGREGATE logging_agg_strict (text)
(
stype = text,
@@ -3501,7 +3501,7 @@ ORDER BY i;
-- that one aggregate restarting doesn't cause others to restart.
CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS
$$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$
-LANGUAGE SQL STRICT;
+LANGUAGE SQLTEST STRICT;
CREATE AGGREGATE sum_int_randomrestart (int4)
(
stype = int4,
@@ -4042,7 +4042,7 @@ AS $$
SELECT array_agg(s) OVER w
FROM generate_series(1,5) s
WINDOW w AS (ORDER BY s ROWS BETWEEN CURRENT ROW AND GROUP_SIZE FOLLOWING)
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQLTEST STABLE;
EXPLAIN (costs off) SELECT * FROM pg_temp.f(2);
QUERY PLAN
------------------------------------------------------
diff --git a/src/test/regress/input/create_function_1.source b/src/test/regress/input/create_function_1.source
index 412e339fcf..c83845b8fe 100644
--- a/src/test/regress/input/create_function_1.source
+++ b/src/test/regress/input/create_function_1.source
@@ -80,19 +80,19 @@ CREATE FUNCTION test_opclass_options_func(internal)
-- Things that shouldn't work:
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT ''not an integer'';';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'not even SQL';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT 1, 2, 3;';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT $2;';
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'a', 'b';
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
diff --git a/src/test/regress/input/create_function_2.source b/src/test/regress/input/create_function_2.source
index 9e6d2942ec..2af7dcaaf7 100644
--- a/src/test/regress/input/create_function_2.source
+++ b/src/test/regress/input/create_function_2.source
@@ -4,62 +4,62 @@
CREATE FUNCTION hobbies(person)
RETURNS setof hobbies_r
AS 'select * from hobbies_r where person = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct(text, text)
RETURNS hobbies_r
AS 'select $1 as name, $2 as hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct_named(name text, hobby text)
RETURNS hobbies_r
AS 'select name, hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE)
RETURNS hobbies_r.person%TYPE
AS 'select person from hobbies_r where name = $1'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment(hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = equipment_named.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1a(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_1a.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1b(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1c(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2a(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_2a.hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2b(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION pt_in_widget(point, widget)
diff --git a/src/test/regress/output/create_function_1.source b/src/test/regress/output/create_function_1.source
index 4d78fa1228..5d3a606f47 100644
--- a/src/test/regress/output/create_function_1.source
+++ b/src/test/regress/output/create_function_1.source
@@ -69,27 +69,27 @@ CREATE FUNCTION test_opclass_options_func(internal)
AS '@libdir@/regress@DLSUFFIX@', 'test_opclass_options_func'
LANGUAGE C;
-- Things that shouldn't work:
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT ''not an integer'';';
ERROR: return type mismatch in function declared to return integer
DETAIL: Actual return type is text.
CONTEXT: SQL function "test1"
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'not even SQL';
ERROR: syntax error at or near "not"
LINE 2: AS 'not even SQL';
^
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT 1, 2, 3;';
ERROR: return type mismatch in function declared to return integer
DETAIL: Final statement must return exactly one column.
CONTEXT: SQL function "test1"
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'SELECT $2;';
ERROR: there is no parameter $2
LINE 2: AS 'SELECT $2;';
^
-CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
+CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQLTEST
AS 'a', 'b';
ERROR: only one AS item needed for language "sql"
CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
diff --git a/src/test/regress/output/create_function_2.source b/src/test/regress/output/create_function_2.source
index ac9a7f5cf8..d98de86161 100644
--- a/src/test/regress/output/create_function_2.source
+++ b/src/test/regress/output/create_function_2.source
@@ -4,49 +4,49 @@
CREATE FUNCTION hobbies(person)
RETURNS setof hobbies_r
AS 'select * from hobbies_r where person = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct(text, text)
RETURNS hobbies_r
AS 'select $1 as name, $2 as hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobby_construct_named(name text, hobby text)
RETURNS hobbies_r
AS 'select name, hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION hobbies_by_name(hobbies_r.name%TYPE)
RETURNS hobbies_r.person%TYPE
AS 'select person from hobbies_r where name = $1'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
NOTICE: type reference hobbies_r.name%TYPE converted to text
NOTICE: type reference hobbies_r.person%TYPE converted to text
CREATE FUNCTION equipment(hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = $1.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = equipment_named.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1a(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_1a.hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1b(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_1c(hobby hobbies_r)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = hobby.name'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2a(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where hobby = equipment_named_ambiguous_2a.hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION equipment_named_ambiguous_2b(hobby text)
RETURNS setof equipment_r
AS 'select * from equipment_r where equipment_r.hobby = hobby'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
CREATE FUNCTION pt_in_widget(point, widget)
RETURNS bool
AS '@libdir@/regress@DLSUFFIX@'
diff --git a/src/test/regress/sql/alter_generic.sql b/src/test/regress/sql/alter_generic.sql
index 8c5d0e5e1f..75fa8f6b6e 100644
--- a/src/test/regress/sql/alter_generic.sql
+++ b/src/test/regress/sql/alter_generic.sql
@@ -26,9 +26,9 @@ SET search_path = alt_nsp1, public;
-- Function and Aggregate
--
SET SESSION AUTHORIZATION regress_alter_generic_user1;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 1';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 1';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 0
@@ -54,9 +54,9 @@ ALTER AGGREGATE alt_agg2(int) OWNER TO regress_alter_generic_user3; -- OK
ALTER AGGREGATE alt_agg2(int) SET SCHEMA alt_nsp2; -- OK
SET SESSION AUTHORIZATION regress_alter_generic_user2;
-CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func1(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 + 2';
-CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sql
+CREATE FUNCTION alt_func2(int) RETURNS int LANGUAGE sqltest
AS 'SELECT $1 - 2';
CREATE AGGREGATE alt_agg1 (
sfunc1 = int4pl, basetype = int4, stype1 = int4, initcond = 100
@@ -354,7 +354,7 @@ DROP OPERATOR FAMILY alt_opf11 USING gist;
-- Should fail. btree comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf12 USING btree;
-CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf12 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf12 USING btree ADD FUNCTION 1 fn_opf12(int4, int2);
DROP OPERATOR FAMILY alt_opf12 USING btree;
ROLLBACK;
@@ -362,7 +362,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should return INTEGER in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf13 USING hash;
-CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf13 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf13 USING hash ADD FUNCTION 1 fn_opf13(int4);
DROP OPERATOR FAMILY alt_opf13 USING hash;
ROLLBACK;
@@ -370,7 +370,7 @@ ROLLBACK;
-- Should fail. btree comparison functions should have two arguments in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf14 USING btree;
-CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf14 (int4) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf14 USING btree ADD FUNCTION 1 fn_opf14(int4);
DROP OPERATOR FAMILY alt_opf14 USING btree;
ROLLBACK;
@@ -378,7 +378,7 @@ ROLLBACK;
-- Should fail. hash comparison functions should have one argument in ALTER OPERATOR FAMILY ... ADD FUNCTION
BEGIN TRANSACTION;
CREATE OPERATOR FAMILY alt_opf15 USING hash;
-CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQL;
+CREATE FUNCTION fn_opf15 (int4, int2) RETURNS BIGINT AS 'SELECT NULL::BIGINT;' LANGUAGE SQLTEST;
ALTER OPERATOR FAMILY alt_opf15 USING hash ADD FUNCTION 1 fn_opf15(int4, int2);
DROP OPERATOR FAMILY alt_opf15 USING hash;
ROLLBACK;
diff --git a/src/test/regress/sql/alter_operator.sql b/src/test/regress/sql/alter_operator.sql
index fd40370165..91f4a2c187 100644
--- a/src/test/regress/sql/alter_operator.sql
+++ b/src/test/regress/sql/alter_operator.sql
@@ -1,5 +1,5 @@
CREATE FUNCTION alter_op_test_fn(boolean, boolean)
-RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sql IMMUTABLE;
+RETURNS boolean AS $$ SELECT NULL::BOOLEAN; $$ LANGUAGE sqltest IMMUTABLE;
CREATE FUNCTION customcontsel(internal, oid, internal, integer)
RETURNS float8 AS 'contsel' LANGUAGE internal STABLE STRICT;
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index 4cc55d8525..4e5af2014c 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -1798,14 +1798,14 @@ drop type lockmodes;
--
create function test_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql returns null on null input;
+ LANGUAGE SQLTEST returns null on null input;
select test_strict(NULL);
alter function test_strict(text) called on null input;
select test_strict(NULL);
create function non_strict(text) returns text as
'select coalesce($1, ''got passed a null'');'
- language sql called on null input;
+ LANGUAGE SQLTEST called on null input;
select non_strict(NULL);
alter function non_strict(text) returns null on null input;
select non_strict(NULL);
@@ -1821,13 +1821,13 @@ create table alter1.t1(f1 serial primary key, f2 int check (f2 > 0));
create view alter1.v1 as select * from alter1.t1;
-create function alter1.plus1(int) returns int as 'select $1+1' language sql;
+create function alter1.plus1(int) returns int as 'select $1+1' LANGUAGE SQLTEST;
create domain alter1.posint integer check (value > 0);
create type alter1.ctype as (f1 int, f2 text);
-create function alter1.same(alter1.ctype, alter1.ctype) returns boolean language sql
+create function alter1.same(alter1.ctype, alter1.ctype) returns boolean LANGUAGE SQLTEST
as 'select $1.f1 is not distinct from $2.f1 and $1.f2 is not distinct from $2.f2';
create operator alter1.=(procedure = alter1.same, leftarg = alter1.ctype, rightarg = alter1.ctype);
@@ -2838,7 +2838,7 @@ drop function func_part_attach();
-- test case where the partitioning operator is a SQL function whose
-- evaluation results in the table's relcache being rebuilt partway through
-- the execution of an ATTACH PARTITION command
-create function at_test_sql_partop (int4, int4) returns int language sql
+create function at_test_sql_partop (int4, int4) returns int LANGUAGE SQLTEST
as $$ select case when $1 = $2 then 0 when $1 > $2 then 1 else -1 end; $$;
create operator class at_test_sql_partop for type int4 using btree as
operator 1 < (int4, int4), operator 2 <= (int4, int4),
diff --git a/src/test/regress/sql/arrays.sql b/src/test/regress/sql/arrays.sql
index c40619a8d5..ca9cfd41da 100644
--- a/src/test/regress/sql/arrays.sql
+++ b/src/test/regress/sql/arrays.sql
@@ -499,13 +499,13 @@ drop type comptype;
create or replace function unnest1(anyarray)
returns setof anyelement as $$
select $1[s] from generate_subscripts($1,1) g(s);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create or replace function unnest2(anyarray)
returns setof anyelement as $$
select $1[s1][s2] from generate_subscripts($1,1) g1(s1),
generate_subscripts($1,2) g2(s2);
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select * from unnest1(array[1,2,3]);
select * from unnest2(array[[1,2,3],[4,5,6]]);
diff --git a/src/test/regress/sql/case.sql b/src/test/regress/sql/case.sql
index 0655d266f6..dce020ea2f 100644
--- a/src/test/regress/sql/case.sql
+++ b/src/test/regress/sql/case.sql
@@ -196,7 +196,7 @@ CREATE FUNCTION volfoo(text) returns foodomain as
'begin return $1::foodomain; end' language plpgsql volatile;
CREATE FUNCTION inline_eq(foodomain, foodomain) returns boolean as
- 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' language sql;
+ 'SELECT CASE $2::text WHEN $1::text THEN true ELSE false END' LANGUAGE SQLTEST;
CREATE OPERATOR = (procedure = inline_eq,
leftarg = foodomain, rightarg = foodomain);
diff --git a/src/test/regress/sql/collate.icu.utf8.sql b/src/test/regress/sql/collate.icu.utf8.sql
index 0de2ed8d85..d4d3a6d8be 100644
--- a/src/test/regress/sql/collate.icu.utf8.sql
+++ b/src/test/regress/sql/collate.icu.utf8.sql
@@ -266,10 +266,10 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
@@ -322,7 +322,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER
SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1;
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
diff --git a/src/test/regress/sql/collate.linux.utf8.sql b/src/test/regress/sql/collate.linux.utf8.sql
index c697c99488..6767fc9379 100644
--- a/src/test/regress/sql/collate.linux.utf8.sql
+++ b/src/test/regress/sql/collate.linux.utf8.sql
@@ -274,10 +274,10 @@ SELECT a, CAST(b AS varchar) FROM collate_test3 ORDER BY 2;
-- propagation of collation in SQL functions (inlined and non-inlined cases)
-- and plpgsql functions too
-CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 $$;
-CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sql
+CREATE FUNCTION mylt_noninline (text, text) RETURNS boolean LANGUAGE sqltest
AS $$ select $1 < $2 limit 1 $$;
CREATE FUNCTION mylt_plpgsql (text, text) RETURNS boolean LANGUAGE plpgsql
@@ -330,7 +330,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER
SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test3)) ORDER BY 1;
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
diff --git a/src/test/regress/sql/collate.sql b/src/test/regress/sql/collate.sql
index 82f9c855b8..f518856165 100644
--- a/src/test/regress/sql/collate.sql
+++ b/src/test/regress/sql/collate.sql
@@ -179,7 +179,7 @@ SELECT a, CAST(b AS varchar) FROM collate_test2 ORDER BY 2;
-- result of a SQL function
-CREATE FUNCTION vc (text) RETURNS text LANGUAGE sql
+CREATE FUNCTION vc (text) RETURNS text LANGUAGE sqltest
AS 'select $1::varchar';
SELECT a, b FROM collate_test1 ORDER BY a, vc(b);
@@ -191,7 +191,7 @@ SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test1)) ORDER
SELECT * FROM unnest((SELECT array_agg(b ORDER BY b) FROM collate_test2)) ORDER BY 1;
CREATE FUNCTION dup (anyelement) RETURNS anyelement
- AS 'select $1' LANGUAGE sql;
+ AS 'select $1' LANGUAGE sqltest;
SELECT a, dup(b) FROM collate_test1 ORDER BY 2;
SELECT a, dup(b) FROM collate_test2 ORDER BY 2;
diff --git a/src/test/regress/sql/create_aggregate.sql b/src/test/regress/sql/create_aggregate.sql
index d4b4036fd7..69b1b97511 100644
--- a/src/test/regress/sql/create_aggregate.sql
+++ b/src/test/regress/sql/create_aggregate.sql
@@ -44,7 +44,7 @@ COMMENT ON AGGREGATE newcnt ("any") IS 'an agg(any) comment';
-- multi-argument aggregate
create function sum3(int8,int8,int8) returns int8 as
-'select $1 + $2 + $3' language sql strict immutable;
+'select $1 + $2 + $3' LANGUAGE SQLTEST strict immutable;
create aggregate sum2(int8,int8) (
sfunc = sum3, stype = int8,
@@ -56,11 +56,11 @@ create type aggtype as (a integer, b integer, c text);
create function aggf_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql strict immutable;
+LANGUAGE SQLTEST strict immutable;
create function aggfns_trans(aggtype[],integer,integer,text) returns aggtype[]
as 'select array_append($1,ROW($2,$3,$4)::aggtype)'
-language sql immutable;
+LANGUAGE SQLTEST immutable;
create aggregate aggfstr(integer,integer,text) (
sfunc = aggf_trans, stype = aggtype[],
@@ -73,7 +73,7 @@ create aggregate aggfns(integer,integer,text) (
);
-- check error cases that would require run-time type coercion
-create function least_accum(int8, int8) returns int8 language sql as
+create function least_accum(int8, int8) returns int8 LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
@@ -83,7 +83,7 @@ create aggregate least_agg(int4) (
drop function least_accum(int8, int8);
create function least_accum(anycompatible, anycompatible)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, $2)';
create aggregate least_agg(int4) (
@@ -98,7 +98,7 @@ drop function least_accum(anycompatible, anycompatible) cascade;
-- variadic aggregates
create function least_accum(anyelement, variadic anyarray)
-returns anyelement language sql as
+returns anyelement LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate least_agg(variadic items anyarray) (
@@ -106,7 +106,7 @@ create aggregate least_agg(variadic items anyarray) (
);
create function cleast_accum(anycompatible, variadic anycompatiblearray)
-returns anycompatible language sql as
+returns anycompatible LANGUAGE SQLTEST as
'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)';
create aggregate cleast_agg(variadic items anycompatiblearray) (
@@ -259,7 +259,7 @@ CREATE OR REPLACE AGGREGATE myavg (order by numeric)
-- can't change plain function to aggregate:
create function sum4(int8,int8,int8,int8) returns int8 as
-'select $1 + $2 + $3 + $4' language sql strict immutable;
+'select $1 + $2 + $3 + $4' LANGUAGE SQLTEST strict immutable;
CREATE OR REPLACE AGGREGATE sum3 (int8,int8,int8)
(
@@ -283,7 +283,7 @@ CREATE AGGREGATE mysum (int)
CREATE FUNCTION float8mi_n(float8, float8) RETURNS float8 AS
$$ SELECT $1 - $2; $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE invalidsumdouble (float8)
(
@@ -298,7 +298,7 @@ CREATE AGGREGATE invalidsumdouble (float8)
CREATE FUNCTION float8mi_int(float8, float8) RETURNS int AS
$$ SELECT CAST($1 - $2 AS INT); $$
-LANGUAGE SQL;
+LANGUAGE SQLTEST;
CREATE AGGREGATE wrongreturntype (float8)
(
diff --git a/src/test/regress/sql/create_cast.sql b/src/test/regress/sql/create_cast.sql
index b11cf88b06..219edd67fc 100644
--- a/src/test/regress/sql/create_cast.sql
+++ b/src/test/regress/sql/create_cast.sql
@@ -22,7 +22,7 @@ CREATE TYPE casttesttype (
);
-- a dummy function to test with
-CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQL AS
+CREATE FUNCTION casttestfunc(casttesttype) RETURNS int4 LANGUAGE SQLTEST AS
$$ SELECT 1; $$;
SELECT casttestfunc('foo'::text); -- fails, as there's no cast
@@ -47,7 +47,7 @@ DROP CAST (int4 AS casttesttype);
-- Try cast with a function
-CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQL AS
+CREATE FUNCTION int4_casttesttype(int4) RETURNS casttesttype LANGUAGE SQLTEST AS
$$ SELECT ('foo'::text || $1::text)::casttesttype; $$;
CREATE CAST (int4 AS casttesttype) WITH FUNCTION int4_casttesttype(int4) AS IMPLICIT;
diff --git a/src/test/regress/sql/create_function_3.sql b/src/test/regress/sql/create_function_3.sql
index bd108a918f..c404f38f7d 100644
--- a/src/test/regress/sql/create_function_3.sql
+++ b/src/test/regress/sql/create_function_3.sql
@@ -20,11 +20,11 @@ SET search_path TO temp_func_test, public;
--
-- ARGUMENT and RETURN TYPES
--
-CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
-CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
+CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sqltest'
AS 'SELECT $1[1]::int';
-CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT false';
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
WHERE oid in ('functest_A_1'::regproc,
@@ -38,13 +38,13 @@ SELECT functest_A_3();
--
-- IMMUTABLE | STABLE | VOLATILE
--
-CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(int) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_3(int) RETURNS bool LANGUAGE 'sqltest'
STABLE AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_4(int) RETURNS bool LANGUAGE 'sqltest'
VOLATILE AS 'SELECT $1 < 0';
SELECT proname, provolatile FROM pg_proc
WHERE oid in ('functest_B_1'::regproc,
@@ -63,11 +63,11 @@ SELECT proname, provolatile FROM pg_proc
--
-- SECURITY DEFINER | INVOKER
--
-CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 0';
-CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_2(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY DEFINER AS 'SELECT $1 = 0';
-CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_C_3(int) RETURNS bool LANGUAGE 'sqltest'
SECURITY INVOKER AS 'SELECT $1 < 0';
SELECT proname, prosecdef FROM pg_proc
WHERE oid in ('functest_C_1'::regproc,
@@ -85,9 +85,9 @@ SELECT proname, prosecdef FROM pg_proc
--
-- LEAKPROOF
--
-CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 100';
-CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_2(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 > 100';
SELECT proname, proleakproof FROM pg_proc
WHERE oid in ('functest_E_1'::regproc,
@@ -113,7 +113,7 @@ SET search_path TO temp_func_test, public;
ALTER FUNCTION functest_E_1(int) NOT LEAKPROOF;
ALTER FUNCTION functest_E_2(int) LEAKPROOF;
-CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_E_3(int) RETURNS bool LANGUAGE 'sqltest'
LEAKPROOF AS 'SELECT $1 < 200'; -- fail
RESET SESSION AUTHORIZATION;
@@ -121,13 +121,13 @@ RESET SESSION AUTHORIZATION;
--
-- CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
--
-CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_1(int) RETURNS bool LANGUAGE 'sqltest'
AS 'SELECT $1 > 50';
-CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_2(int) RETURNS bool LANGUAGE 'sqltest'
CALLED ON NULL INPUT AS 'SELECT $1 = 50';
-CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_3(int) RETURNS bool LANGUAGE 'sqltest'
RETURNS NULL ON NULL INPUT AS 'SELECT $1 < 50';
-CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_F_4(int) RETURNS bool LANGUAGE 'sqltest'
STRICT AS 'SELECT $1 = 50';
SELECT proname, proisstrict FROM pg_proc
WHERE oid in ('functest_F_1'::regproc,
@@ -157,17 +157,17 @@ SELECT pg_get_functiondef('functest_F_2'::regproc);
CREATE FUNCTION functest_IS_1(a int, b int default 1, c text default 'foo')
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1 + $2';
CREATE FUNCTION functest_IS_2(out a int, b int default 1)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
CREATE FUNCTION functest_IS_3(a int default 1, out b int)
RETURNS int
- LANGUAGE SQL
+ LANGUAGE SQLTEST
AS 'SELECT $1';
SELECT routine_name, ordinal_position, parameter_name, parameter_default
@@ -178,7 +178,7 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
-- overload
-CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sql'
+CREATE FUNCTION functest_B_2(bigint) RETURNS bool LANGUAGE 'sqltest'
IMMUTABLE AS 'SELECT $1 > 0';
DROP FUNCTION functest_b_1;
@@ -188,19 +188,19 @@ DROP FUNCTION functest_b_2; -- error, ambiguous
-- CREATE OR REPLACE tests
-CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL AS 'SELECT $1';
-CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQL WINDOW AS 'SELECT $1';
-CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQL AS 'SELECT $1';
+CREATE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST AS 'SELECT $1';
+CREATE OR REPLACE FUNCTION functest1(a int) RETURNS int LANGUAGE SQLTEST WINDOW AS 'SELECT $1';
+CREATE OR REPLACE PROCEDURE functest1(a int) LANGUAGE SQLTEST AS 'SELECT $1';
DROP FUNCTION functest1(a int);
-- Check behavior of VOID-returning SQL functions
-CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest1(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT a + 1 $$;
SELECT voidtest1(42);
-CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest2(a int, b int) RETURNS VOID LANGUAGE SQLTEST AS
$$ SELECT voidtest1(a + b) $$;
SELECT voidtest2(11,22);
@@ -209,17 +209,17 @@ EXPLAIN (verbose, costs off) SELECT voidtest2(11,22);
CREATE TEMP TABLE sometable(f1 int);
-CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest3(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a + 1) $$;
SELECT voidtest3(17);
-CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest4(a int) RETURNS VOID LANGUAGE SQLTEST AS
$$ INSERT INTO sometable VALUES(a - 1) RETURNING f1 $$;
SELECT voidtest4(39);
TABLE sometable;
-CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQL AS
+CREATE FUNCTION voidtest5(a int) RETURNS SETOF VOID LANGUAGE SQLTEST AS
$$ SELECT generate_series(1, a) $$ STABLE;
SELECT * FROM voidtest5(3);
diff --git a/src/test/regress/sql/create_operator.sql b/src/test/regress/sql/create_operator.sql
index 4ff2c0ff21..ebf1eddab7 100644
--- a/src/test/regress/sql/create_operator.sql
+++ b/src/test/regress/sql/create_operator.sql
@@ -117,7 +117,7 @@ BEGIN TRANSACTION;
CREATE OR REPLACE FUNCTION fn_op2(boolean, boolean)
RETURNS boolean AS $$
SELECT NULL::BOOLEAN;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
CREATE OPERATOR === (
LEFTARG = boolean,
RIGHTARG = boolean,
@@ -154,7 +154,7 @@ CREATE TYPE type_op3 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op3(type_op3, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op3 FROM regress_rol_op3;
REVOKE USAGE ON TYPE type_op3 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op3;
@@ -172,7 +172,7 @@ CREATE TYPE type_op4 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op4(int8, type_op4)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op4 FROM regress_rol_op4;
REVOKE USAGE ON TYPE type_op4 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op4;
@@ -190,7 +190,7 @@ CREATE TYPE type_op5 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op5(int8, int8)
RETURNS int8 AS $$
SELECT NULL::int8;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM regress_rol_op5;
REVOKE EXECUTE ON FUNCTION fn_op5(int8, int8) FROM PUBLIC;-- Need to do this so that regress_rol_op3 is not allowed EXECUTE via PUBLIC
SET ROLE regress_rol_op5;
@@ -208,7 +208,7 @@ CREATE TYPE type_op6 AS ENUM ('new', 'open', 'closed');
CREATE FUNCTION fn_op6(int8, int8)
RETURNS type_op6 AS $$
SELECT NULL::type_op6;
-$$ LANGUAGE sql IMMUTABLE;
+$$ LANGUAGE sqltest IMMUTABLE;
REVOKE USAGE ON TYPE type_op6 FROM regress_rol_op6;
REVOKE USAGE ON TYPE type_op6 FROM PUBLIC; -- Need to do this so that regress_rol_op3 is not allowed USAGE via PUBLIC
SET ROLE regress_rol_op6;
diff --git a/src/test/regress/sql/create_procedure.sql b/src/test/regress/sql/create_procedure.sql
index 2ef1c82cea..110ce78891 100644
--- a/src/test/regress/sql/create_procedure.sql
+++ b/src/test/regress/sql/create_procedure.sql
@@ -1,12 +1,12 @@
CALL nonexistent(); -- error
CALL random(); -- error
-CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQL AS $$ SELECT a $$;
+CREATE FUNCTION cp_testfunc1(a int) RETURNS int LANGUAGE SQLTEST AS $$ SELECT a $$;
CREATE TABLE cp_test (a int, b text);
CREATE PROCEDURE ptest1(x text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, x);
$$;
@@ -29,7 +29,7 @@ SELECT * FROM cp_test ORDER BY b COLLATE "C";
CREATE PROCEDURE ptest2()
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 5;
$$;
@@ -41,7 +41,7 @@ CALL ptest2();
TRUNCATE cp_test;
CREATE PROCEDURE ptest3(y text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest1(y);
CALL ptest1($1);
@@ -55,7 +55,7 @@ SELECT * FROM cp_test;
-- output arguments
CREATE PROCEDURE ptest4a(INOUT a int, INOUT b int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT 1, 2;
$$;
@@ -63,7 +63,7 @@ $$;
CALL ptest4a(NULL, NULL);
CREATE PROCEDURE ptest4b(INOUT b int, INOUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
CALL ptest4a(a, b); -- error, not supported
$$;
@@ -74,7 +74,7 @@ DROP PROCEDURE ptest4a;
-- named and default parameters
CREATE OR REPLACE PROCEDURE ptest5(a int, b text, c int default 100)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES(a, b);
INSERT INTO cp_test VALUES(c, b);
@@ -93,7 +93,7 @@ SELECT * FROM cp_test;
-- polymorphic types
CREATE PROCEDURE ptest6(a int, b anyelement)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT NULL::int;
$$;
@@ -104,7 +104,7 @@ CALL ptest6(1, 2);
-- collation assignment
CREATE PROCEDURE ptest7(a text, b text)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT a = b;
$$;
@@ -115,7 +115,7 @@ CALL ptest7(least('a', 'b'), 'a');
-- OUT parameters
CREATE PROCEDURE ptest9(OUT a int)
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
INSERT INTO cp_test VALUES (1, 'a');
SELECT 1;
@@ -129,8 +129,8 @@ CALL ptest9(NULL);
CALL version(); -- error: not a procedure
CALL sum(1); -- error: not a procedure
-CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
-CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
+CREATE PROCEDURE ptestx() LANGUAGE SQLTEST STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
ALTER PROCEDURE ptest1(text) STRICT;
ALTER FUNCTION ptest1(text) VOLATILE; -- error: not a function
diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql
index d257679ba6..048d10a50e 100644
--- a/src/test/regress/sql/create_table.sql
+++ b/src/test/regress/sql/create_table.sql
@@ -355,7 +355,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a);
-- prevent using prohibited expressions in the key
-CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION retset (a int) RETURNS SETOF int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (retset(a));
@@ -378,7 +378,7 @@ CREATE TABLE partitioned (
a int
) PARTITION BY RANGE ((42));
-CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQL IMMUTABLE;
+CREATE FUNCTION const_func () RETURNS int AS $$ SELECT 1; $$ LANGUAGE SQLTEST IMMUTABLE;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (const_func());
@@ -410,7 +410,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a, ('unknown'));
-- functions in key must be immutable
-CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQL;
+CREATE FUNCTION immut_func (a int) RETURNS int AS $$ SELECT a + random()::int; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int
) PARTITION BY RANGE (immut_func(a));
@@ -437,7 +437,7 @@ CREATE TABLE partitioned (
) PARTITION BY RANGE (a);
-- some checks after successful creation of a partitioned table
-CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQL;
+CREATE FUNCTION plusone(a int) RETURNS INT AS $$ SELECT a+1; $$ LANGUAGE SQLTEST;
CREATE TABLE partitioned (
a int,
@@ -866,7 +866,7 @@ CREATE TABLE range_parted4_3 PARTITION OF range_parted4 FOR VALUES FROM (6, 8, M
DROP TABLE range_parted4;
-- user-defined operator class in partition key
-CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql
+CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sqltest
AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$;
CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING btree AS
OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4),
diff --git a/src/test/regress/sql/create_type.sql b/src/test/regress/sql/create_type.sql
index a32a9e6795..e0eda962b7 100644
--- a/src/test/regress/sql/create_type.sql
+++ b/src/test/regress/sql/create_type.sql
@@ -117,7 +117,7 @@ CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42);
CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS '
SELECT * FROM default_test;
-' LANGUAGE SQL;
+' LANGUAGE SQLTEST;
SELECT * FROM get_default_test();
diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql
index 549c0b5adf..bd0438dc3e 100644
--- a/src/test/regress/sql/domain.sql
+++ b/src/test/regress/sql/domain.sql
@@ -724,7 +724,7 @@ drop domain di;
--
create function sql_is_distinct_from(anyelement, anyelement)
-returns boolean language sql
+returns boolean LANGUAGE SQLTEST
as 'select $1 is distinct from $2 limit 1';
create domain inotnull int
diff --git a/src/test/regress/sql/drop_if_exists.sql b/src/test/regress/sql/drop_if_exists.sql
index ac6168b91f..020d32d00f 100644
--- a/src/test/regress/sql/drop_if_exists.sql
+++ b/src/test/regress/sql/drop_if_exists.sql
@@ -274,8 +274,8 @@ DROP VIEW IF EXISTS no_such_schema.foo;
-- Check we receive an ambiguous function error when there are
-- multiple matching functions.
-CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ language sql;
-CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ language sql;
+CREATE FUNCTION test_ambiguous_funcname(int) returns int as $$ select $1; $$ LANGUAGE SQLTEST;
+CREATE FUNCTION test_ambiguous_funcname(text) returns text as $$ select $1; $$ LANGUAGE SQLTEST;
DROP FUNCTION test_ambiguous_funcname;
DROP FUNCTION IF EXISTS test_ambiguous_funcname;
diff --git a/src/test/regress/sql/event_trigger.sql b/src/test/regress/sql/event_trigger.sql
index 18b2a267cb..ae028331c1 100644
--- a/src/test/regress/sql/event_trigger.sql
+++ b/src/test/regress/sql/event_trigger.sql
@@ -19,7 +19,7 @@ returns event_trigger as $$ BEGIN RETURN 1; END $$ language plpgsql;
-- should fail, SQL functions cannot be event triggers
create function test_event_trigger_sql() returns event_trigger as $$
-SELECT 1 $$ language sql;
+SELECT 1 $$ LANGUAGE SQLTEST;
-- should fail, no elephant_bootstrap entry point
create event trigger regress_event_trigger on elephant_bootstrap
diff --git a/src/test/regress/sql/foreign_data.sql b/src/test/regress/sql/foreign_data.sql
index 73f9f621d8..437bd1be27 100644
--- a/src/test/regress/sql/foreign_data.sql
+++ b/src/test/regress/sql/foreign_data.sql
@@ -52,7 +52,7 @@ CREATE FOREIGN DATA WRAPPER foo VALIDATOR postgresql_fdw_validator;
\dew+
-- HANDLER related checks
-CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQL AS 'SELECT 1;';
+CREATE FUNCTION invalid_fdw_handler() RETURNS int LANGUAGE SQLTEST AS 'SELECT 1;';
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER invalid_fdw_handler; -- ERROR
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler HANDLER invalid_fdw_handler; -- ERROR
CREATE FOREIGN DATA WRAPPER test_fdw HANDLER test_fdw_handler;
diff --git a/src/test/regress/sql/generated.sql b/src/test/regress/sql/generated.sql
index bd2b0bfaaa..49fa1da9c7 100644
--- a/src/test/regress/sql/generated.sql
+++ b/src/test/regress/sql/generated.sql
@@ -226,7 +226,7 @@ CREATE TABLE gtest11s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (b *
INSERT INTO gtest11s VALUES (1, 10), (2, 20);
GRANT SELECT (a, c) ON gtest11s TO regress_user11;
-CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQL;
+CREATE FUNCTION gf1(a int) RETURNS int AS $$ SELECT a * 3 $$ IMMUTABLE LANGUAGE SQLTEST;
REVOKE ALL ON FUNCTION gf1(int) FROM PUBLIC;
CREATE TABLE gtest12s (a int PRIMARY KEY, b int, c int GENERATED ALWAYS AS (gf1(b)) STORED);
diff --git a/src/test/regress/sql/guc.sql b/src/test/regress/sql/guc.sql
index 43dbba3775..ec986f226c 100644
--- a/src/test/regress/sql/guc.sql
+++ b/src/test/regress/sql/guc.sql
@@ -205,7 +205,7 @@ reset search_path;
set work_mem = '3MB';
create function report_guc(text) returns text as
-$$ select current_setting($1) $$ language sql
+$$ select current_setting($1) $$ LANGUAGE SQLTEST
set work_mem = '1MB';
select report_guc('work_mem'), current_setting('work_mem');
@@ -280,13 +280,13 @@ select current_setting('nosuch.setting', true);
-- because that creates ordering hazards for pg_dump
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
set check_function_bodies = off;
create function func_with_bad_set() returns int as $$ select 1 $$
-language sql
+LANGUAGE SQLTEST
set default_text_search_config = no_such_config;
select func_with_bad_set();
diff --git a/src/test/regress/sql/infinite_recurse.sql b/src/test/regress/sql/infinite_recurse.sql
index 151dba4a7a..c3f4f3ae6d 100644
--- a/src/test/regress/sql/infinite_recurse.sql
+++ b/src/test/regress/sql/infinite_recurse.sql
@@ -2,7 +2,7 @@
-- max_stack_depth is not set too high.
create function infinite_recurse() returns int as
-'select infinite_recurse()' language sql;
+'select infinite_recurse()' LANGUAGE SQLTEST;
-- Unfortunately, up till mid 2020 the Linux kernel had a bug in PPC64
-- signal handling that would cause this test to crash if it happened
diff --git a/src/test/regress/sql/inherit.sql b/src/test/regress/sql/inherit.sql
index 64173a8738..fe1cb7775c 100644
--- a/src/test/regress/sql/inherit.sql
+++ b/src/test/regress/sql/inherit.sql
@@ -251,7 +251,7 @@ drop table base;
create table p1(ff1 int);
create table p2(f1 text);
-create function p2text(p2) returns text as 'select $1.f1' language sql;
+create function p2text(p2) returns text as 'select $1.f1' LANGUAGE SQLTEST;
create table c1(f3 int) inherits(p1,p2);
insert into c1 values(123456789, 'hi', 42);
select p2text(c1.*) from c1;
diff --git a/src/test/regress/sql/insert.sql b/src/test/regress/sql/insert.sql
index 963faa1614..06cad2c9f5 100644
--- a/src/test/regress/sql/insert.sql
+++ b/src/test/regress/sql/insert.sql
@@ -236,7 +236,7 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p
create or replace function part_hashint4_noop(value int4, seed int8)
returns int8 as $$
select value + seed;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_int4_ops
for type int4
@@ -247,7 +247,7 @@ function 2 part_hashint4_noop(int4, int8);
create or replace function part_hashtext_length(value text, seed int8)
RETURNS int8 AS $$
select length(coalesce(value, ''))::int8
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
create operator class part_test_text_ops
for type text
diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql
index 6a209a27aa..1acefbcf2b 100644
--- a/src/test/regress/sql/join.sql
+++ b/src/test/regress/sql/join.sql
@@ -1135,10 +1135,10 @@ drop function f_immutable_int4(int);
-- test inlining when function returns composite
create function mki8(bigint, bigint) returns int8_tbl as
-$$select row($1,$2)::int8_tbl$$ language sql;
+$$select row($1,$2)::int8_tbl$$ LANGUAGE SQLTEST;
create function mki4(int) returns int4_tbl as
-$$select row($1)::int4_tbl$$ language sql;
+$$select row($1)::int4_tbl$$ LANGUAGE SQLTEST;
explain (verbose, costs off)
select * from mki8(1,2);
diff --git a/src/test/regress/sql/multirangetypes.sql b/src/test/regress/sql/multirangetypes.sql
index 692f2416d9..176812969d 100644
--- a/src/test/regress/sql/multirangetypes.sql
+++ b/src/test/regress/sql/multirangetypes.sql
@@ -630,7 +630,7 @@ drop type textrange2;
--
create function anyarray_anymultirange_func(a anyarray, r anymultirange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anymultirange_func(ARRAY[1,2], int4multirange(int4range(10,20)));
@@ -641,27 +641,27 @@ drop function anyarray_anymultirange_func(anyarray, anymultirange);
-- should fail
create function bogus_func(anyelement)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
-- should fail
create function bogus_func(int)
- returns anymultirange as 'select int4multirange(int4range(1,10))' language sql;
+ returns anymultirange as 'select int4multirange(int4range(1,10))' LANGUAGE SQLTEST;
create function range_add_bounds(anymultirange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4multirange(int4range(1, 17)));
select range_add_bounds(nummultirange(numrange(1.0001, 123.123)));
create function multirangetypes_sql(q anymultirange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select multirangetypes_sql(int4multirange(int4range(1,10)), ARRAY[2,20]);
select multirangetypes_sql(nummultirange(numrange(1,10)), ARRAY[2,20]); -- match failure
create function anycompatiblearray_anycompatiblemultirange_func(a anycompatiblearray, mr anycompatiblemultirange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1,2], multirange(int4range(10,20)));
@@ -673,7 +673,7 @@ select anycompatiblearray_anycompatiblemultirange_func(ARRAY[1.1,2], multirange(
drop function anycompatiblearray_anycompatiblemultirange_func(anycompatiblearray, anycompatiblemultirange);
create function anycompatiblerange_anycompatiblemultirange_func(r anycompatiblerange, mr anycompatiblemultirange)
- returns anycompatible as 'select lower($1) + lower($2);' language sql;
+ returns anycompatible as 'select lower($1) + lower($2);' LANGUAGE SQLTEST;
select anycompatiblerange_anycompatiblemultirange_func(int4range(1,2), multirange(int4range(10,20)));
@@ -684,7 +684,7 @@ drop function anycompatiblerange_anycompatiblemultirange_func(anycompatiblerange
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
--
-- Arrays of multiranges
@@ -737,36 +737,36 @@ reset enable_sort;
-- infer anymultirange from anymultirange
create function mr_outparam_succeed(i anymultirange, out r anymultirange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed(int4multirange(int4range(1,2)));
-- infer anyarray from anymultirange
create function mr_outparam_succeed2(i anymultirange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed2(int4multirange(int4range(1,2)));
-- infer anyrange from anymultirange
create function mr_outparam_succeed3(i anymultirange, out r anyrange, out t text)
- as $$ select range_merge($1), 'foo'::text $$ language sql;
+ as $$ select range_merge($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed3(int4multirange(int4range(1,2)));
-- infer anymultirange from anyrange
create function mr_outparam_succeed4(i anyrange, out r anymultirange, out t text)
- as $$ select multirange($1), 'foo'::text $$ language sql;
+ as $$ select multirange($1), 'foo'::text $$ LANGUAGE SQLTEST;
select * from mr_outparam_succeed4(int4range(1,2));
-- infer anyelement from anymultirange
create function mr_inoutparam_succeed(out i anyelement, inout r anymultirange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from mr_inoutparam_succeed(int4multirange(int4range(1,2)));
-- infer anyelement+anymultirange from anyelement+anymultirange
create function mr_table_succeed(i anyelement, r anymultirange) returns table(i anyelement, r anymultirange)
- as $$ select $1, $2 $$ language sql;
+ as $$ select $1, $2 $$ LANGUAGE SQLTEST;
select * from mr_table_succeed(123, int4multirange(int4range(1,11)));
@@ -777,12 +777,12 @@ select mr_polymorphic(int4range(1, 4));
-- should fail
create function mr_outparam_fail(i anyelement, out r anymultirange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
--should fail
create function mr_inoutparam_fail(inout i anyelement, out r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
--should fail
create function mr_table_fail(i anyelement) returns table(i anyelement, r anymultirange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
diff --git a/src/test/regress/sql/object_address.sql b/src/test/regress/sql/object_address.sql
index 2f4f66e3e1..7926fb77c6 100644
--- a/src/test/regress/sql/object_address.sql
+++ b/src/test/regress/sql/object_address.sql
@@ -35,14 +35,14 @@ CREATE DOMAIN addr_nsp.gendomain AS int4 CONSTRAINT domconstr CHECK (value > 0);
CREATE FUNCTION addr_nsp.trig() RETURNS TRIGGER LANGUAGE plpgsql AS $$ BEGIN END; $$;
CREATE TRIGGER t BEFORE INSERT ON addr_nsp.gentable FOR EACH ROW EXECUTE PROCEDURE addr_nsp.trig();
CREATE POLICY genpol ON addr_nsp.gentable;
-CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQL AS $$ $$;
+CREATE PROCEDURE addr_nsp.proc(int4) LANGUAGE SQLTEST AS $$ $$;
CREATE SERVER "integer" FOREIGN DATA WRAPPER addr_fdw;
CREATE USER MAPPING FOR regress_addr_user SERVER "integer";
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user IN SCHEMA public GRANT ALL ON TABLES TO regress_addr_user;
ALTER DEFAULT PRIVILEGES FOR ROLE regress_addr_user REVOKE DELETE ON TABLES FROM regress_addr_user;
-- this transform would be quite unsafe to leave lying around,
-- except that the SQL language pays no attention to transforms:
-CREATE TRANSFORM FOR int LANGUAGE SQL (
+CREATE TRANSFORM FOR int LANGUAGE SQLTEST (
FROM SQL WITH FUNCTION prsd_lextype(internal),
TO SQL WITH FUNCTION int4recv(internal));
-- suppress warning that depends on wal_level
@@ -271,7 +271,7 @@ WITH objects (classid, objid, objsubid) AS (VALUES
('pg_policy'::regclass, 0, 0), -- no policy
('pg_publication'::regclass, 0, 0), -- no publication
('pg_publication_rel'::regclass, 0, 0), -- no publication relation
- ('pg_subscription'::regclass, 0, 0), -- no subscription
+ ('pg_sub'::regclass, 0, 0), -- no subscription
('pg_transform'::regclass, 0, 0) -- no transformation
)
SELECT ROW(pg_identify_object(objects.classid, objects.objid, objects.objsubid))
diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql
index 781666a83a..2d1bb17554 100644
--- a/src/test/regress/sql/plpgsql.sql
+++ b/src/test/regress/sql/plpgsql.sql
@@ -3610,11 +3610,11 @@ $$ language plpgsql;
-- "limit" is to prevent this from being inlined
create function sql_recurse(float8) returns float8 as
-$$ select recurse($1) limit 1; $$ language sql;
+$$ select recurse($1) limit 1; $$ LANGUAGE SQLTEST;
select recurse(10);
-create function error1(text) returns text language sql as
+create function error1(text) returns text LANGUAGE SQLTEST as
$$ SELECT relname::text FROM pg_class c WHERE c.oid = $1::regclass $$;
create function error2(p_name_table text) returns text language plpgsql as $$
@@ -3637,7 +3637,7 @@ drop function error1(text);
create function sql_to_date(integer) returns date as $$
select $1::text::date
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
create cast (integer as date) with function sql_to_date(integer) as assignment;
diff --git a/src/test/regress/sql/polymorphism.sql b/src/test/regress/sql/polymorphism.sql
index 891b023ada..5529f99671 100644
--- a/src/test/regress/sql/polymorphism.sql
+++ b/src/test/regress/sql/polymorphism.sql
@@ -5,7 +5,7 @@
create function polyf(x anyelement) returns anyelement as $$
select x + 1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
select polyf(point(3,4)); -- fail for lack of + operator
@@ -14,7 +14,7 @@ drop function polyf(x anyelement);
create function polyf(x anyelement) returns anyarray as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(42) as int, polyf(4.5) as num;
@@ -22,7 +22,7 @@ drop function polyf(x anyelement);
create function polyf(x anyarray) returns anyelement as $$
select x[1]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
@@ -32,7 +32,7 @@ drop function polyf(x anyarray);
create function polyf(x anyarray) returns anyarray as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(array[2,4]) as int, polyf(array[4.5, 7.7]) as num;
@@ -43,11 +43,11 @@ drop function polyf(x anyarray);
-- fail, can't infer type:
create function polyf(x anyelement) returns anyrange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function polyf(x anyrange) returns anyarray as $$
select array[lower(x), upper(x)]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49)) as int, polyf(float8range(4.5, 7.8)) as num;
@@ -55,7 +55,7 @@ drop function polyf(x anyrange);
create function polyf(x anycompatible, y anycompatible) returns anycompatiblearray as $$
select array[x, y]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(2, 4) as int, polyf(2, 4.5) as num;
@@ -63,7 +63,7 @@ drop function polyf(x anycompatible, y anycompatible);
create function polyf(x anycompatiblerange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), 11, 2::smallint) as int, polyf(float8range(4.5, 7.8), 7.8, 11::real) as num;
@@ -73,7 +73,7 @@ drop function polyf(x anycompatiblerange, y anycompatible, z anycompatible);
create function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible) returns anycompatiblearray as $$
select array[lower(x), upper(x), y, z]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), 11, 2::smallint) as int, polyf(multirange(float8range(4.5, 7.8)), 7.8, 11::real) as num;
@@ -84,11 +84,11 @@ drop function polyf(x anycompatiblemultirange, y anycompatible, z anycompatible)
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblerange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function polyf(x anycompatiblerange, y anycompatiblearray) returns anycompatiblerange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(int4range(42, 49), array[11]) as int, polyf(float8range(4.5, 7.8), array[7]) as num;
@@ -97,11 +97,11 @@ drop function polyf(x anycompatiblerange, y anycompatiblearray);
-- fail, can't infer type:
create function polyf(x anycompatible) returns anycompatiblemultirange as $$
select array[x + 1, x + 2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function polyf(x anycompatiblemultirange, y anycompatiblearray) returns anycompatiblemultirange as $$
select x
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select polyf(multirange(int4range(42, 49)), array[11]) as int, polyf(multirange(float8range(4.5, 7.8)), array[7]) as num;
@@ -112,7 +112,7 @@ create function polyf(a anyelement, b anyarray,
OUT x anyarray, OUT y anycompatiblearray)
as $$
select a || b, array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x), y, pg_typeof(y)
from polyf(11, array[1, 2], 42, 34.5);
@@ -166,35 +166,35 @@ drop function polyf(a anyelement, b anyarray,
-- polymorphic single arg transfn
CREATE FUNCTION stfp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- non-polymorphic single arg transfn
CREATE FUNCTION stfnp(int[]) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- dual polymorphic transfn
CREATE FUNCTION tfp(anyarray,anyelement) RETURNS anyarray AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- dual non-polymorphic transfn
CREATE FUNCTION tfnp(int[],int) RETURNS int[] AS
-'select $1 || $2' LANGUAGE SQL;
+'select $1 || $2' LANGUAGE SQLTEST;
-- arg1 only polymorphic transfn
CREATE FUNCTION tf1p(anyarray,int) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- arg2 only polymorphic transfn
CREATE FUNCTION tf2p(int[],anyelement) RETURNS int[] AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- multi-arg polymorphic
CREATE FUNCTION sum3(anyelement,anyelement,anyelement) returns anyelement AS
-'select $1+$2+$3' language sql strict;
+'select $1+$2+$3' LANGUAGE SQLTEST strict;
-- finalfn polymorphic
CREATE FUNCTION ffp(anyarray) RETURNS anyarray AS
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- finalfn non-polymorphic
CREATE FUNCTION ffnp(int[]) returns int[] as
-'select $1' LANGUAGE SQL;
+'select $1' LANGUAGE SQLTEST;
-- Try to cover all the possible states:
--
@@ -511,7 +511,7 @@ begin
end$$ language plpgsql;
create function sql_if(bool, anyelement, anyelement) returns anyelement as $$
-select case when $1 then $2 else $3 end $$ language sql;
+select case when $1 then $2 else $3 end $$ LANGUAGE SQLTEST;
-- Note this would fail with integer overflow, never mind wrong bleat() output,
-- if the CASE expression were not successfully inlined
@@ -573,10 +573,10 @@ create aggregate build_group(int8, integer) (
-- check proper resolution of data types for polymorphic transfn/finalfn
create function first_el_transfn(anyarray, anyelement) returns anyarray as
-'select $1 || $2' language sql immutable;
+'select $1 || $2' LANGUAGE SQLTEST immutable;
create function first_el(anyarray) returns anyelement as
-'select $1[1]' language sql strict immutable;
+'select $1[1]' LANGUAGE SQLTEST strict immutable;
create aggregate first_el_agg_f8(float8) (
SFUNC = array_append,
@@ -612,7 +612,7 @@ select anyrange_in('[10,20)','int4range'::regtype,-1);
create function myleast(variadic anyarray) returns anyelement as $$
select min($1[i]) from generate_subscripts($1,1) g(i)
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select myleast(10, 1, 20, 33);
select myleast(1.1, 0.22, 0.55);
@@ -629,7 +629,7 @@ select myleast(variadic array[]::int[]);
-- an example with some ordinary arguments too
create function concat(text, variadic anyarray) returns text as $$
select array_to_string($2, $1);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select concat('%', 1, 2, 3, 4, 5);
select concat('|', 'a'::text, 'b', 'c');
@@ -641,7 +641,7 @@ drop function concat(text, anyarray);
-- mix variadic with anyelement
create function formarray(anyelement, variadic anyarray) returns anyarray as $$
select array_prepend($1, $2);
-$$ language sql immutable strict;
+$$ LANGUAGE SQLTEST immutable strict;
select formarray(1,2,3,4,5);
select formarray(1.1, variadic array[1.2,55.5]);
@@ -667,7 +667,7 @@ select pg_typeof(myleast(10, 1, 20, 33)); -- polymorphic input
-- test basic functionality
create function dfunc(a int = 1, int = 2) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
select dfunc(10);
@@ -681,12 +681,12 @@ drop function dfunc(int, int); -- ok
-- fail: defaults must be at end of argument list
create function dfunc(a int = 1, b int) returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- however, this should work:
create function dfunc(a int = 1, out sum int, b int = 2) as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
@@ -698,12 +698,12 @@ drop function dfunc(int, int);
-- check implicit coercion
create function dfunc(a int DEFAULT 1.0, int DEFAULT '-1') returns int as $$
select $1 + $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
create function dfunc(a text DEFAULT 'Hello', b text DEFAULT 'World') returns text as $$
select $1 || ', ' || $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(); -- fail: which dfunc should be called? int or text
select dfunc('Hi'); -- ok
@@ -716,11 +716,11 @@ drop function dfunc(text, text);
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2, int = 3, int = 4) returns int as $$
select 4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- Now, dfunc(nargs = 2) and dfunc(nargs = 4) are ambiguous when called
-- with 0 to 2 arguments.
@@ -737,12 +737,12 @@ drop function dfunc(int, int, int, int);
-- default values are not allowed for output parameters
create function dfunc(out int = 20) returns int as $$
select 1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- polymorphic parameter test
create function dfunc(anyelement = 'World'::text) returns text as $$
select 'Hello, ' || $1::text;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc();
select dfunc(0);
@@ -754,14 +754,14 @@ drop function dfunc(anyelement);
-- check defaults for variadics
create function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- fail
select dfunc(10);
select dfunc(10,20);
create or replace function dfunc(a variadic int[] default array[]::int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
select dfunc(); -- now ok
select dfunc(10);
@@ -769,7 +769,7 @@ select dfunc(10,20);
-- can't remove the default once it exists
create or replace function dfunc(a variadic int[]) returns int as
-$$ select array_upper($1, 1) $$ language sql;
+$$ select array_upper($1, 1) $$ LANGUAGE SQLTEST;
\df dfunc
@@ -779,15 +779,15 @@ drop function dfunc(a variadic int[]);
create function dfunc(int = 1, int = 2, int = 3) returns int as $$
select 3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(int = 1, int = 2) returns int as $$
select 2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function dfunc(text) returns text as $$
select $1;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
-- dfunc(narg=2) and dfunc(narg=3) are ambiguous
select dfunc(1); -- fail
@@ -806,7 +806,7 @@ drop function dfunc(text);
create function dfunc(a int, b int, c int = 0, d int = 0)
returns table (a int, b int, c int, d int) as $$
select $1, $2, $3, $4;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc(10,20,30)).*;
select (dfunc(a := 10, b := 20, c := 30)).*;
@@ -829,7 +829,7 @@ drop function dfunc(int, int, int, int);
create function dfunc(a varchar, b numeric, c date = current_date)
returns table (a varchar, b numeric, c date) as $$
select $1, $2, $3;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc('Hello World', 20, '2009-07-25'::date)).*;
select * from dfunc('Hello World', 20, '2009-07-25'::date);
@@ -844,7 +844,7 @@ drop function dfunc(varchar, numeric, date);
create function dfunc(a varchar = 'def a', out _a varchar, c numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select (dfunc()).*;
select * from dfunc();
@@ -859,26 +859,26 @@ select * from dfunc(c := 100);
create or replace function dfunc(a varchar = 'def a', out _a varchar, x numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create or replace function dfunc(a varchar = 'def a', out _a varchar, numeric = NULL, out _c numeric)
returns record as $$
select $1, $2;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
drop function dfunc(varchar, numeric);
--fail, named parameters are not unique
-create function testpolym(a int, a int) returns int as $$ select 1;$$ language sql;
-create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ language sql;
-create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ language sql;
-create function testpolym(a int, inout a int) returns int as $$ select 1;$$ language sql;
+create function testpolym(a int, a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
+create function testpolym(int, out a int, out a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
+create function testpolym(out a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
+create function testpolym(a int, inout a int) returns int as $$ select 1;$$ LANGUAGE SQLTEST;
-- valid
-create function testpolym(a int, out a int) returns int as $$ select $1;$$ language sql;
+create function testpolym(a int, out a int) returns int as $$ select $1;$$ LANGUAGE SQLTEST;
select testpolym(37);
drop function testpolym(int);
-create function testpolym(a int) returns table(a int) as $$ select $1;$$ language sql;
+create function testpolym(a int) returns table(a int) as $$ select $1;$$ LANGUAGE SQLTEST;
select * from testpolym(37);
drop function testpolym(int);
@@ -886,7 +886,7 @@ drop function testpolym(int);
create function dfunc(a anyelement, b anyelement = null, flag bool = true)
returns anyelement as $$
select case when $3 then $1 else $2 end;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select dfunc(1,2);
select dfunc('a'::text, 'b'); -- positional notation with default
@@ -957,7 +957,7 @@ drop function dfunc(anyelement, anyelement, bool);
create function anyctest(anycompatible, anycompatible)
returns anycompatible as $$
select greatest($1, $2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.3) x;
@@ -969,7 +969,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatible)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.3) x;
@@ -980,7 +980,7 @@ drop function anyctest(anycompatible, anycompatible);
create function anyctest(anycompatible, anycompatiblearray)
returns anycompatiblearray as $$
select array[$1] || $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[12]) x;
select x, pg_typeof(x) from anyctest(11, array[12.3]) x;
@@ -994,7 +994,7 @@ drop function anyctest(anycompatible, anycompatiblearray);
create function anyctest(anycompatible, anycompatiblerange)
returns anycompatiblerange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, int4range(4,7)) x;
select x, pg_typeof(x) from anyctest(11, numrange(4,7)) x;
@@ -1007,7 +1007,7 @@ drop function anyctest(anycompatible, anycompatiblerange);
create function anyctest(anycompatiblerange, anycompatiblerange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(int4range(11,12), int4range(4,7)) x;
select x, pg_typeof(x) from anyctest(int4range(11,12), numrange(4,7)) x; -- fail
@@ -1018,12 +1018,12 @@ drop function anyctest(anycompatiblerange, anycompatiblerange);
create function anyctest(anycompatible)
returns anycompatiblerange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function anyctest(anycompatible, anycompatiblemultirange)
returns anycompatiblemultirange as $$
select $2
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, multirange(int4range(4,7))) x;
select x, pg_typeof(x) from anyctest(11, multirange(numrange(4,7))) x;
@@ -1036,7 +1036,7 @@ drop function anyctest(anycompatible, anycompatiblemultirange);
create function anyctest(anycompatiblemultirange, anycompatiblemultirange)
returns anycompatible as $$
select lower($1) + upper($2)
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(int4range(4,7))) x;
select x, pg_typeof(x) from anyctest(multirange(int4range(11,12)), multirange(numrange(4,7))) x; -- fail
@@ -1047,12 +1047,12 @@ drop function anyctest(anycompatiblemultirange, anycompatiblemultirange);
create function anyctest(anycompatible)
returns anycompatiblemultirange as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function anyctest(anycompatiblenonarray, anycompatiblenonarray)
returns anycompatiblearray as $$
select array[$1, $2]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.3) x;
@@ -1064,7 +1064,7 @@ create function anyctest(a anyelement, b anyarray,
c anycompatible, d anycompatible)
returns anycompatiblearray as $$
select array[c, d]
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, array[1, 2], 42, 34.5) x;
select x, pg_typeof(x) from anyctest(11, array[1, 2], point(1,2), point(3,4)) x;
@@ -1077,7 +1077,7 @@ drop function anyctest(a anyelement, b anyarray,
create function anyctest(variadic anycompatiblearray)
returns anycompatiblearray as $$
select $1
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select x, pg_typeof(x) from anyctest(11, 12) x;
select x, pg_typeof(x) from anyctest(11, 12.2) x;
diff --git a/src/test/regress/sql/portals.sql b/src/test/regress/sql/portals.sql
index 52560ac027..f540fee4d1 100644
--- a/src/test/regress/sql/portals.sql
+++ b/src/test/regress/sql/portals.sql
@@ -239,7 +239,7 @@ BEGIN;
CREATE FUNCTION declares_cursor(text)
RETURNS void
AS 'DECLARE c CURSOR FOR SELECT stringu1 FROM tenk1 WHERE stringu1 LIKE $1;'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT declares_cursor('AB%');
@@ -256,10 +256,10 @@ ROLLBACK;
create temp table tt1(f1 int);
create function count_tt1_v() returns int8 as
-'select count(*) from tt1' language sql volatile;
+'select count(*) from tt1' LANGUAGE SQLTEST volatile;
create function count_tt1_s() returns int8 as
-'select count(*) from tt1' language sql stable;
+'select count(*) from tt1' LANGUAGE SQLTEST stable;
begin;
@@ -512,7 +512,7 @@ DROP TABLE cursor;
-- per bug report in 8336843.9833.1399385291498.JavaMail.root@quick
begin;
create function nochange(int) returns int
- as 'select $1 limit 1' language sql stable;
+ as 'select $1 limit 1' LANGUAGE SQLTEST stable;
declare c cursor for select * from int8_tbl limit nochange(3);
fetch all from c;
move backward all in c;
diff --git a/src/test/regress/sql/privileges.sql b/src/test/regress/sql/privileges.sql
index 6277140cfd..ab4bcced9e 100644
--- a/src/test/regress/sql/privileges.sql
+++ b/src/test/regress/sql/privileges.sql
@@ -540,16 +540,16 @@ END;
-- switch to superuser
\c -
-REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user1; -- ok
+REVOKE ALL PRIVILEGES ON LANGUAGE sqltest FROM PUBLIC;
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user1; -- ok
GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
SET SESSION AUTHORIZATION regress_priv_user1;
-GRANT USAGE ON LANGUAGE sql TO regress_priv_user2; -- fail
-CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql;
-CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+GRANT USAGE ON LANGUAGE sqltest TO regress_priv_user2; -- fail
+CREATE FUNCTION priv_testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest;
+CREATE FUNCTION priv_testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE priv_testagg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sql;
+CREATE PROCEDURE priv_testproc1(int) AS 'select $1;' LANGUAGE sqltest;
REVOKE ALL ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION priv_testfunc1(int), priv_testfunc2(int), priv_testagg1(int) TO regress_priv_user2;
@@ -566,12 +566,12 @@ GRANT ALL PRIVILEGES ON PROCEDURE priv_testproc1(int) TO regress_priv_user4;
CREATE FUNCTION priv_testfunc4(boolean) RETURNS text
AS 'select col1 from atest2 where col2 = $1;'
- LANGUAGE sql SECURITY DEFINER;
+ LANGUAGE sqltest SECURITY DEFINER;
GRANT EXECUTE ON FUNCTION priv_testfunc4(boolean) TO regress_priv_user3;
SET SESSION AUTHORIZATION regress_priv_user2;
SELECT priv_testfunc1(5), priv_testfunc2(5); -- ok
-CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql; -- fail
+CREATE FUNCTION priv_testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sqltest; -- fail
SELECT priv_testagg1(x) FROM (VALUES (1), (2), (3)) _(x); -- ok
CALL priv_testproc1(6); -- ok
@@ -595,7 +595,7 @@ DROP PROCEDURE priv_testproc1(int); -- fail
DROP FUNCTION priv_testfunc1(int); -- ok
-- restore to sanity
-GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
+GRANT ALL PRIVILEGES ON LANGUAGE sqltest TO PUBLIC;
-- verify privilege checks on array-element coercions
BEGIN;
@@ -631,13 +631,13 @@ CREATE AGGREGATE priv_testagg1a(priv_testdomain1) (sfunc = int4_sum, stype = big
CREATE DOMAIN priv_testdomain2a AS priv_testdomain1;
CREATE DOMAIN priv_testdomain3a AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3a AS $$ SELECT $1::priv_testdomain3a $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3a) WITH FUNCTION castfunc(int);
DROP FUNCTION castfunc(int) CASCADE;
DROP DOMAIN priv_testdomain3a;
-CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
-CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc5a(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc6a(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
CREATE OPERATOR !+! (PROCEDURE = int4pl, LEFTARG = priv_testdomain1, RIGHTARG = priv_testdomain1);
@@ -668,11 +668,11 @@ CREATE AGGREGATE priv_testagg1b(priv_testdomain1) (sfunc = int4_sum, stype = big
CREATE DOMAIN priv_testdomain2b AS priv_testdomain1;
CREATE DOMAIN priv_testdomain3b AS int;
-CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQL;
+CREATE FUNCTION castfunc(int) RETURNS priv_testdomain3b AS $$ SELECT $1::priv_testdomain3b $$ LANGUAGE SQLTEST;
CREATE CAST (priv_testdomain1 AS priv_testdomain3b) WITH FUNCTION castfunc(int);
-CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQL AS $$ SELECT $1 $$;
-CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQL AS $$ SELECT $1::priv_testdomain1 $$;
+CREATE FUNCTION priv_testfunc5b(a priv_testdomain1) RETURNS int LANGUAGE SQLTEST AS $$ SELECT $1 $$;
+CREATE FUNCTION priv_testfunc6b(b int) RETURNS priv_testdomain1 LANGUAGE SQLTEST AS $$ SELECT $1::priv_testdomain1 $$;
CREATE OPERATOR !! (PROCEDURE = priv_testfunc5b, RIGHTARG = priv_testdomain1);
@@ -872,9 +872,9 @@ SELECT has_table_privilege('regress_priv_user1', 'atest4', 'SELECT WITH GRANT OP
CREATE ROLE regress_sro_user;
SET SESSION AUTHORIZATION regress_sro_user;
-CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sql AS
+CREATE FUNCTION unwanted_grant() RETURNS void LANGUAGE sqltest AS
'GRANT regress_priv_group2 TO regress_sro_user';
-CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'DECLARE c CURSOR WITH HOLD FOR SELECT unwanted_grant(); SELECT true';
-- REFRESH of this MV will queue a GRANT at end of transaction
CREATE MATERIALIZED VIEW sro_mv AS SELECT mv_action() WITH NO DATA;
@@ -890,7 +890,7 @@ CREATE FUNCTION sro_trojan() RETURNS trigger LANGUAGE plpgsql AS
CREATE CONSTRAINT TRIGGER t AFTER INSERT ON sro_trojan_table
INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE sro_trojan();
-- Now, REFRESH will issue such an INSERT, queueing the GRANT
-CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sql AS
+CREATE OR REPLACE FUNCTION mv_action() RETURNS bool LANGUAGE sqltest AS
'INSERT INTO sro_trojan_table DEFAULT VALUES; SELECT true';
REFRESH MATERIALIZED VIEW sro_mv;
\c -
@@ -904,7 +904,7 @@ DROP ROLE regress_sro_user;
-- Admin options
SET SESSION AUTHORIZATION regress_priv_user4;
-CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: had ADMIN OPTION
SET ROLE regress_priv_group2;
@@ -918,7 +918,7 @@ GRANT regress_priv_group2 TO regress_priv_user5; -- fails: SET ROLE did not help
SET SESSION AUTHORIZATION regress_priv_group2;
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: a role can self-admin
-CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sql SECURITY DEFINER AS
+CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sqltest SECURITY DEFINER AS
'GRANT regress_priv_group2 TO regress_priv_user5';
SELECT dogrant_fails(); -- fails: no self-admin in SECURITY DEFINER
DROP FUNCTION dogrant_fails();
@@ -1135,9 +1135,9 @@ SELECT has_schema_privilege('regress_priv_user2', 'testns5', 'CREATE'); -- no
SET ROLE regress_priv_user1;
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- no
SELECT has_function_privilege('regress_priv_user2', 'testns.agg1(int)', 'EXECUTE'); -- no
@@ -1146,11 +1146,11 @@ SELECT has_function_privilege('regress_priv_user2', 'testns.bar()', 'EXECUTE');
ALTER DEFAULT PRIVILEGES IN SCHEMA testns GRANT EXECUTE ON ROUTINES to public;
DROP FUNCTION testns.foo();
-CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sql;
+CREATE FUNCTION testns.foo() RETURNS int AS 'select 1' LANGUAGE sqltest;
DROP AGGREGATE testns.agg1(int);
CREATE AGGREGATE testns.agg1(int) (sfunc = int4pl, stype = int4);
DROP PROCEDURE testns.bar();
-CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sql;
+CREATE PROCEDURE testns.bar() AS 'select 1' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user2', 'testns.foo()', 'EXECUTE'); -- yes
SELECT has_function_privilege('regress_priv_user2', 'testns.agg1(int)', 'EXECUTE'); -- yes
@@ -1211,9 +1211,9 @@ REVOKE ALL ON ALL TABLES IN SCHEMA testns FROM regress_priv_user1;
SELECT has_table_privilege('regress_priv_user1', 'testns.t1', 'SELECT'); -- false
SELECT has_table_privilege('regress_priv_user1', 'testns.t2', 'SELECT'); -- false
-CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql;
+CREATE FUNCTION testns.priv_testfunc(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sqltest;
CREATE AGGREGATE testns.priv_testagg(int) (sfunc = int4pl, stype = int4);
-CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sql;
+CREATE PROCEDURE testns.priv_testproc(int) AS 'select 3' LANGUAGE sqltest;
SELECT has_function_privilege('regress_priv_user1', 'testns.priv_testfunc(int)', 'EXECUTE'); -- true by default
SELECT has_function_privilege('regress_priv_user1', 'testns.priv_testagg(int)', 'EXECUTE'); -- true by default
@@ -1322,7 +1322,7 @@ DROP GROUP regress_priv_group1;
DROP GROUP regress_priv_group2;
-- these are needed to clean up permissions
-REVOKE USAGE ON LANGUAGE sql FROM regress_priv_user1;
+REVOKE USAGE ON LANGUAGE sqltest FROM regress_priv_user1;
DROP OWNED BY regress_priv_user1;
DROP USER regress_priv_user1;
diff --git a/src/test/regress/sql/rangefuncs.sql b/src/test/regress/sql/rangefuncs.sql
index 3c436028da..6ab1f10b01 100644
--- a/src/test/regress/sql/rangefuncs.sql
+++ b/src/test/regress/sql/rangefuncs.sql
@@ -3,7 +3,7 @@ INSERT INTO rngfunc2 VALUES(1, 11);
INSERT INTO rngfunc2 VALUES(2, 22);
INSERT INTO rngfunc2 VALUES(1, 111);
-CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQL;
+CREATE FUNCTION rngfunct(int) returns setof rngfunc2 as 'SELECT * FROM rngfunc2 WHERE rngfuncid = $1 ORDER BY f2;' LANGUAGE SQLTEST;
-- function with ORDINALITY
select * from rngfunct(1) with ordinality as z(a,b,ord);
@@ -88,7 +88,7 @@ INSERT INTO rngfunc VALUES(1,2,'Ed');
INSERT INTO rngfunc VALUES(2,1,'Mary');
-- sql, proretset = f, prorettype = b
-CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc1(int) RETURNS int AS 'SELECT $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc1(1) AS t1;
SELECT * FROM getrngfunc1(1) WITH ORDINALITY AS t1(v,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc1(1);
@@ -99,7 +99,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc2(int) RETURNS setof int AS 'SELECT rngfuncid FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc2(1) AS t1;
SELECT * FROM getrngfunc2(1) WITH ORDINALITY AS t1(v,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc2(1);
@@ -110,7 +110,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = b
-CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc3(int) RETURNS setof text AS 'SELECT rngfuncname FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc3(1) AS t1;
SELECT * FROM getrngfunc3(1) WITH ORDINALITY AS t1(v,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc3(1);
@@ -121,7 +121,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = c
-CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc4(int) RETURNS rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc4(1) AS t1;
SELECT * FROM getrngfunc4(1) WITH ORDINALITY AS t1(a,b,c,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc4(1);
@@ -132,7 +132,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = c
-CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc5(int) RETURNS setof rngfunc AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc5(1) AS t1;
SELECT * FROM getrngfunc5(1) WITH ORDINALITY AS t1(a,b,c,o);
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc5(1);
@@ -143,7 +143,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = f, prorettype = record
-CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc6(int) RETURNS RECORD AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc6(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
SELECT * FROM ROWS FROM( getrngfunc6(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY;
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc6(1) AS
@@ -157,7 +157,7 @@ SELECT * FROM vw_getrngfunc;
DROP VIEW vw_getrngfunc;
-- sql, proretset = t, prorettype = record
-CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQL;
+CREATE FUNCTION getrngfunc7(int) RETURNS setof record AS 'SELECT * FROM rngfunc WHERE rngfuncid = $1;' LANGUAGE SQLTEST;
SELECT * FROM getrngfunc7(1) AS t1(rngfuncid int, rngfuncsubid int, rngfuncname text);
SELECT * FROM ROWS FROM( getrngfunc7(1) AS (rngfuncid int, rngfuncsubid int, rngfuncname text) ) WITH ORDINALITY;
CREATE VIEW vw_getrngfunc AS SELECT * FROM getrngfunc7(1) AS
@@ -232,7 +232,7 @@ CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq1;
CREATE TEMPORARY SEQUENCE rngfunc_rescan_seq2;
CREATE TYPE rngfunc_rescan_t AS (i integer, s bigint);
-CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQL;
+CREATE FUNCTION rngfunc_sql(int,int) RETURNS setof rngfunc_rescan_t AS 'SELECT i, nextval(''rngfunc_rescan_seq1'') FROM generate_series($1,$2) i;' LANGUAGE SQLTEST;
-- plpgsql functions use materialize mode
CREATE FUNCTION rngfunc_mat(int,int) RETURNS setof rngfunc_rescan_t AS 'begin for i in $1..$2 loop return next (i, nextval(''rngfunc_rescan_seq2'')); end loop; end;' LANGUAGE plpgsql;
@@ -344,32 +344,32 @@ DROP SEQUENCE rngfunc_rescan_seq2;
--
CREATE FUNCTION rngfunc(in f1 int, out f2 int)
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
SELECT rngfunc(42);
SELECT * FROM rngfunc(42);
SELECT * FROM rngfunc(42) AS p(x);
-- explicit spec of return type is OK
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
-- error, wrong result type
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int) RETURNS float
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
-- with multiple OUT params you must get a RECORD result
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text) RETURNS int
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
CREATE OR REPLACE FUNCTION rngfunc(in f1 int, out f2 int, out f3 text)
RETURNS record
-AS 'select $1+1' LANGUAGE sql;
+AS 'select $1+1' LANGUAGE sqltest;
CREATE OR REPLACE FUNCTION rngfuncr(in f1 int, out f2 int, out text)
-AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $1-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncr(f1) FROM int4_tbl;
SELECT * FROM rngfuncr(42);
SELECT * FROM rngfuncr(42) AS p(a,b);
CREATE OR REPLACE FUNCTION rngfuncb(in f1 int, inout f2 int, out text)
-AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sql;
+AS $$select $2-1, $1::text || 'z'$$ LANGUAGE sqltest;
SELECT f1, rngfuncb(f1, f1/2) FROM int4_tbl;
SELECT * FROM rngfuncb(42, 99);
SELECT * FROM rngfuncb(42, 99) AS p(a,b);
@@ -384,7 +384,7 @@ DROP FUNCTION rngfuncb(in f1 int, inout f2 int);
--
CREATE FUNCTION dup (f1 anyelement, f2 out anyelement, f3 out anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
SELECT dup('xyz'); -- fails
SELECT dup('xyz'::text);
@@ -392,23 +392,23 @@ SELECT * FROM dup('xyz'::text);
-- fails, as we are attempting to rename first argument
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
DROP FUNCTION dup(anyelement);
-- equivalent behavior, though different name exposed for input arg
CREATE OR REPLACE FUNCTION dup (inout f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
SELECT dup(22);
DROP FUNCTION dup(anyelement);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 int, out f2 anyelement, out f3 anyarray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
CREATE FUNCTION dup (f1 anycompatible, f2 anycompatiblearray, f3 out anycompatible, f4 out anycompatiblearray)
-AS 'select $1, $2' LANGUAGE sql;
+AS 'select $1, $2' LANGUAGE sqltest;
SELECT dup(22, array[44]);
SELECT dup(4.5, array[44]);
SELECT dup(22, array[44::bigint]);
@@ -417,7 +417,7 @@ SELECT *, pg_typeof(f3), pg_typeof(f4) FROM dup(22, array[44::bigint]);
DROP FUNCTION dup(f1 anycompatible, f2 anycompatiblearray);
CREATE FUNCTION dup (f1 anycompatiblerange, f2 out anycompatible, f3 out anycompatiblearray, f4 out anycompatiblerange)
-AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sql;
+AS 'select lower($1), array[lower($1), upper($1)], $1' LANGUAGE sqltest;
SELECT dup(int4range(4,7));
SELECT dup(numrange(4,7));
SELECT dup(textrange('aaa', 'bbb'));
@@ -426,7 +426,7 @@ DROP FUNCTION dup(f1 anycompatiblerange);
-- fails, no way to deduce outputs
CREATE FUNCTION bad (f1 anyarray, out f2 anycompatible, out f3 anycompatiblearray)
-AS 'select $1, array[$1,$1]' LANGUAGE sql;
+AS 'select $1, array[$1,$1]' LANGUAGE sqltest;
--
-- table functions
@@ -434,7 +434,7 @@ AS 'select $1, array[$1,$1]' LANGUAGE sql;
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a int)
-AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sql;
+AS $$ SELECT a FROM generate_series(1,5) a(a) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc();
DROP FUNCTION rngfunc();
@@ -442,14 +442,14 @@ CREATE OR REPLACE FUNCTION rngfunc(int)
RETURNS TABLE(a int, b int)
AS $$ SELECT a, b
FROM generate_series(1,$1) a(a),
- generate_series(1,$1) b(b) $$ LANGUAGE sql;
+ generate_series(1,$1) b(b) $$ LANGUAGE sqltest;
SELECT * FROM rngfunc(3);
DROP FUNCTION rngfunc(int);
-- case that causes change of typmod knowledge during inlining
CREATE OR REPLACE FUNCTION rngfunc()
RETURNS TABLE(a varchar(5))
-AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sql STABLE;
+AS $$ SELECT 'hello'::varchar(5) $$ LANGUAGE sqltest STABLE;
SELECT * FROM rngfunc() GROUP BY 1;
DROP FUNCTION rngfunc();
@@ -461,7 +461,7 @@ create temp table tt(f1 serial, data text);
create function insert_tt(text) returns int as
$$ insert into tt(data) values($1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('foo');
select insert_tt('bar');
@@ -470,7 +470,7 @@ select * from tt;
-- insert will execute to completion even if function needs just 1 row
create or replace function insert_tt(text) returns int as
$$ insert into tt(data) values($1),($1||$1) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt('fool');
select * from tt;
@@ -478,7 +478,7 @@ select * from tt;
-- setof does what's expected
create or replace function insert_tt2(text,text) returns setof int as
$$ insert into tt(data) values($1),($2) returning f1 $$
-language sql;
+LANGUAGE SQLTEST;
select insert_tt2('foolish','barrish');
select * from insert_tt2('baz','quux');
@@ -515,7 +515,7 @@ select * from tt_log;
-- test case for a whole-row-variable bug
create function rngfunc1(n integer, out a text, out b text)
returns setof record
- language sql
+ LANGUAGE SQLTEST
as $$ select 'foo ' || i, 'bar ' || i from generate_series(1,$1) i $$;
set work_mem='64kB';
@@ -531,7 +531,7 @@ drop function rngfunc1(n integer);
create function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql strict immutable;
+$$ LANGUAGE SQLTEST strict immutable;
select array_to_set(array['one', 'two']);
select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text);
@@ -549,7 +549,7 @@ explain (verbose, costs off)
create or replace function array_to_set(anyarray) returns setof record as $$
select i AS "index", $1[i] AS "value" from generate_subscripts($1, 1) i
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
select array_to_set(array['one', 'two']);
select * from array_to_set(array['one', 'two']) as t(f1 int,f2 text);
@@ -562,7 +562,7 @@ create temp table rngfunc(f1 int8, f2 int8);
create function testrngfunc() returns record as $$
insert into rngfunc values (1,2) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
select * from testrngfunc() as t(f1 int8,f2 int8);
@@ -572,7 +572,7 @@ drop function testrngfunc();
create function testrngfunc() returns setof record as $$
insert into rngfunc values (1,2), (3,4) returning *;
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select testrngfunc();
select * from testrngfunc() as t(f1 int8,f2 int8);
@@ -585,7 +585,7 @@ create type rngfunc_type as (f1 numeric(35,6), f2 numeric(35,2));
create function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
@@ -596,7 +596,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
@@ -609,7 +609,7 @@ drop function testrngfunc();
create function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
@@ -620,7 +620,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 7.136178319899999964, 7.136178319899999964;
-$$ language sql volatile;
+$$ LANGUAGE SQLTEST volatile;
explain (verbose, costs off)
select testrngfunc();
@@ -631,7 +631,7 @@ select * from testrngfunc();
create or replace function testrngfunc() returns setof rngfunc_type as $$
select 1, 2 union select 3, 4 order by 1;
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select testrngfunc();
@@ -658,14 +658,14 @@ alter table users drop column todrop;
create or replace function get_first_user() returns users as
$$ SELECT * FROM users ORDER BY userid LIMIT 1; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_first_user();
SELECT * FROM get_first_user();
create or replace function get_users() returns setof users as
$$ SELECT * FROM users ORDER BY userid; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
SELECT get_users();
SELECT * FROM get_users();
@@ -698,7 +698,7 @@ drop table users;
create or replace function rngfuncbar() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar ; $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select rngfuncbar();
select * from rngfuncbar();
@@ -710,17 +710,17 @@ drop function rngfuncbar();
-- check handling of a SQL function with multiple OUT params (bug #5777)
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1) $$ language sql;
+$$ select (1, 2.1) $$ LANGUAGE SQLTEST;
select * from rngfuncbar();
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2) $$ language sql;
+$$ select (1, 2) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
create or replace function rngfuncbar(out integer, out numeric) as
-$$ select (1, 2.1, 3) $$ language sql;
+$$ select (1, 2.1, 3) $$ LANGUAGE SQLTEST;
select * from rngfuncbar(); -- fail
@@ -730,7 +730,7 @@ drop function rngfuncbar();
create function extractq2(t int8_tbl) returns int8 as $$
select t.q2
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2(int8_tbl) f(x);
@@ -739,7 +739,7 @@ select x from int8_tbl, extractq2(int8_tbl) f(x);
create function extractq2_2(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t) offset 0
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2(int8_tbl) f(x);
@@ -750,7 +750,7 @@ select x from int8_tbl, extractq2_2(int8_tbl) f(x);
create function extractq2_2_opt(t int8_tbl) returns table(ret1 int8) as $$
select extractq2(t)
-$$ language sql immutable;
+$$ LANGUAGE SQLTEST immutable;
explain (verbose, costs off)
select x from int8_tbl, extractq2_2_opt(int8_tbl) f(x);
diff --git a/src/test/regress/sql/rangetypes.sql b/src/test/regress/sql/rangetypes.sql
index e1b8917c0c..a65130f78b 100644
--- a/src/test/regress/sql/rangetypes.sql
+++ b/src/test/regress/sql/rangetypes.sql
@@ -465,7 +465,7 @@ drop type textrange2;
--
create function anyarray_anyrange_func(a anyarray, r anyrange)
- returns anyelement as 'select $1[1] + lower($2);' language sql;
+ returns anyelement as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anyarray_anyrange_func(ARRAY[1,2], int4range(10,20));
@@ -476,27 +476,27 @@ drop function anyarray_anyrange_func(anyarray, anyrange);
-- should fail
create function bogus_func(anyelement)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
-- should fail
create function bogus_func(int)
- returns anyrange as 'select int4range(1,10)' language sql;
+ returns anyrange as 'select int4range(1,10)' LANGUAGE SQLTEST;
create function range_add_bounds(anyrange)
- returns anyelement as 'select lower($1) + upper($1)' language sql;
+ returns anyelement as 'select lower($1) + upper($1)' LANGUAGE SQLTEST;
select range_add_bounds(int4range(1, 17));
select range_add_bounds(numrange(1.0001, 123.123));
create function rangetypes_sql(q anyrange, b anyarray, out c anyelement)
as $$ select upper($1) + $2[1] $$
- language sql;
+ LANGUAGE SQLTEST;
select rangetypes_sql(int4range(1,10), ARRAY[2,20]);
select rangetypes_sql(numrange(1,10), ARRAY[2,20]); -- match failure
create function anycompatiblearray_anycompatiblerange_func(a anycompatiblearray, r anycompatiblerange)
- returns anycompatible as 'select $1[1] + lower($2);' language sql;
+ returns anycompatible as 'select $1[1] + lower($2);' LANGUAGE SQLTEST;
select anycompatiblearray_anycompatiblerange_func(ARRAY[1,2], int4range(10,20));
@@ -509,7 +509,7 @@ drop function anycompatiblearray_anycompatiblerange_func(anycompatiblearray, any
-- should fail
create function bogus_func(anycompatible)
- returns anycompatiblerange as 'select int4range(1,10)' language sql;
+ returns anycompatiblerange as 'select int4range(1,10)' LANGUAGE SQLTEST;
--
-- Arrays of ranges
@@ -569,43 +569,43 @@ reset enable_sort;
-- infer anyrange from anyrange
create function outparam_succeed(i anyrange, out r anyrange, out t text)
- as $$ select $1, 'foo'::text $$ language sql;
+ as $$ select $1, 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed(int4range(1,2));
create function outparam2_succeed(r anyrange, out lu anyarray, out ul anyarray)
as $$ select array[lower($1), upper($1)], array[upper($1), lower($1)] $$
- language sql;
+ LANGUAGE SQLTEST;
select * from outparam2_succeed(int4range(1,11));
-- infer anyarray from anyrange
create function outparam_succeed2(i anyrange, out r anyarray, out t text)
- as $$ select ARRAY[upper($1)], 'foo'::text $$ language sql;
+ as $$ select ARRAY[upper($1)], 'foo'::text $$ LANGUAGE SQLTEST;
select * from outparam_succeed2(int4range(int4range(1,2)));
-- infer anyelement from anyrange
create function inoutparam_succeed(out i anyelement, inout r anyrange)
- as $$ select upper($1), $1 $$ language sql;
+ as $$ select upper($1), $1 $$ LANGUAGE SQLTEST;
select * from inoutparam_succeed(int4range(1,2));
create function table_succeed(r anyrange)
returns table(l anyelement, u anyelement)
as $$ select lower($1), upper($1) $$
- language sql;
+ LANGUAGE SQLTEST;
select * from table_succeed(int4range(1,11));
-- should fail
create function outparam_fail(i anyelement, out r anyrange, out t text)
- as $$ select '[1,10]', 'foo' $$ language sql;
+ as $$ select '[1,10]', 'foo' $$ LANGUAGE SQLTEST;
--should fail
create function inoutparam_fail(inout i anyelement, out r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
--should fail
create function table_fail(i anyelement) returns table(i anyelement, r anyrange)
- as $$ select $1, '[1,10]' $$ language sql;
+ as $$ select $1, '[1,10]' $$ LANGUAGE SQLTEST;
diff --git a/src/test/regress/sql/rowtypes.sql b/src/test/regress/sql/rowtypes.sql
index 845e3305f3..d5613d287c 100644
--- a/src/test/regress/sql/rowtypes.sql
+++ b/src/test/regress/sql/rowtypes.sql
@@ -331,11 +331,11 @@ CREATE TYPE price_key AS (
CREATE FUNCTION price_key_from_table(price) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
CREATE FUNCTION price_key_from_input(price_input) RETURNS price_key AS $$
SELECT $1.id
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
insert into price values (1,false,42), (10,false,100), (11,true,17.99);
@@ -357,19 +357,19 @@ create temp table compos (f1 int, f2 text);
create function fcompos1(v compos) returns void as $$
insert into compos values (v); -- fail
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos1(v compos) returns void as $$
insert into compos values (v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos2(v compos) returns void as $$
select fcompos1(v);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
create function fcompos3(v compos) returns void as $$
select fcompos1(fcompos3.v.*);
-$$ language sql;
+$$ LANGUAGE SQLTEST;
select fcompos1(row(1,'one'));
select fcompos2(row(2,'two'));
@@ -399,7 +399,7 @@ insert into fullname values ('Joe', 'Blow');
select f.last from fullname f;
select last(f) from fullname f;
-create function longname(fullname) returns text language sql
+create function longname(fullname) returns text LANGUAGE SQLTEST
as $$select $1.first || ' ' || $1.last$$;
select f.longname from fullname f;
diff --git a/src/test/regress/sql/rules.sql b/src/test/regress/sql/rules.sql
index 6ec37c4381..5eeb1955b8 100644
--- a/src/test/regress/sql/rules.sql
+++ b/src/test/regress/sql/rules.sql
@@ -431,7 +431,7 @@ create view rtest_vview4 as select X.a, X.b, count(Y.a) as refcount
group by X.a, X.b;
create function rtest_viewfunc1(int4) returns int4 as
'select count(*)::int4 from rtest_view2 where a = $1'
- language sql;
+ LANGUAGE SQLTEST;
create view rtest_vview5 as select a, b, rtest_viewfunc1(a) as refcount
from rtest_view1;
@@ -1186,7 +1186,7 @@ drop table hat_data;
-- Note that the function is kept around to stress pg_dump.
CREATE FUNCTION func_with_set_params() RETURNS integer
AS 'select 1;'
- LANGUAGE SQL
+ LANGUAGE SQLTEST
SET search_path TO PG_CATALOG
SET extra_float_digits TO 2
SET work_mem TO '4MB'
diff --git a/src/test/regress/sql/select.sql b/src/test/regress/sql/select.sql
index b5929b2eca..30cbc2e0e7 100644
--- a/src/test/regress/sql/select.sql
+++ b/src/test/regress/sql/select.sql
@@ -243,7 +243,7 @@ SELECT 1 AS x ORDER BY x;
-- But ORDER BY on a set-valued expression does
create function sillysrf(int) returns setof int as
- 'values (1),(10),(2),($1)' language sql immutable;
+ 'values (1),(10),(2),($1)' LANGUAGE SQLTEST immutable;
select sillysrf(42);
select sillysrf(-1) order by 1;
diff --git a/src/test/regress/sql/select_into.sql b/src/test/regress/sql/select_into.sql
index 7e903c339a..5dbf9cbe9f 100644
--- a/src/test/regress/sql/select_into.sql
+++ b/src/test/regress/sql/select_into.sql
@@ -90,7 +90,7 @@ DROP TABLE ctas_nodata_4;
CREATE FUNCTION make_table() RETURNS VOID
AS $$
CREATE TABLE created_table AS SELECT * FROM int8_tbl;
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQLTEST;
SELECT make_table();
diff --git a/src/test/regress/sql/select_parallel.sql b/src/test/regress/sql/select_parallel.sql
index 5a01a98b26..705a4d9478 100644
--- a/src/test/regress/sql/select_parallel.sql
+++ b/src/test/regress/sql/select_parallel.sql
@@ -52,7 +52,7 @@ reset enable_parallel_append;
-- Parallel Append that runs serially
create function sp_test_func() returns setof text as
$$ select 'foo'::varchar union all select 'bar'::varchar $$
-language sql stable;
+LANGUAGE SQLTEST stable;
select sp_test_func() order by 1;
-- Parallel Append is not to be used when the subpath depends on the outer param
diff --git a/src/test/regress/sql/subscription.sql b/src/test/regress/sql/subscription.sql
index 14fa0b247e..4929dbb3bd 100644
--- a/src/test/regress/sql/subscription.sql
+++ b/src/test/regress/sql/subscription.sql
@@ -28,7 +28,7 @@ CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUB
CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false);
COMMENT ON SUBSCRIPTION regress_testsub IS 'test subscription';
-SELECT obj_description(s.oid, 'pg_subscription') FROM pg_subscription s;
+SELECT obj_description(s.oid, 'pg_sub') FROM pg_sub s;
-- fail - name already exists
CREATE SUBSCRIPTION regress_testsub CONNECTION 'dbname=regress_doesnotexist' PUBLICATION testpub WITH (connect = false);
diff --git a/src/test/regress/sql/subselect.sql b/src/test/regress/sql/subselect.sql
index bd17f5d264..1f00fc0f5a 100644
--- a/src/test/regress/sql/subselect.sql
+++ b/src/test/regress/sql/subselect.sql
@@ -481,7 +481,7 @@ begin;
-- make an operator to allow it to succeed
create function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2';
create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text);
@@ -492,7 +492,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function results in unusual number of hash clauses,
-- which we can still cope with
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $1::text = $2 and $1::text = $2';
+LANGUAGE SQLTEST as 'select $1::text = $2 and $1::text = $2';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
@@ -501,7 +501,7 @@ select * from int8_tbl where q1 in (select c1 from inner_text);
-- inlining of this function causes LHS and RHS to be switched,
-- which we can't cope with, so hashing should be abandoned
create or replace function bogus_int8_text_eq(int8, text) returns boolean
-language sql as 'select $2 = $1::text';
+LANGUAGE SQLTEST as 'select $2 = $1::text';
explain (costs off)
select * from int8_tbl where q1 in (select c1 from inner_text);
diff --git a/src/test/regress/sql/temp.sql b/src/test/regress/sql/temp.sql
index 424d12b283..abd25c2b85 100644
--- a/src/test/regress/sql/temp.sql
+++ b/src/test/regress/sql/temp.sql
@@ -131,10 +131,10 @@ create temp table whereami (f1 text);
insert into whereami values ('temp');
create function public.whoami() returns text
- as $$select 'public'::text$$ language sql;
+ as $$select 'public'::text$$ LANGUAGE SQLTEST;
create function pg_temp.whoami() returns text
- as $$select 'temp'::text$$ language sql;
+ as $$select 'temp'::text$$ LANGUAGE SQLTEST;
-- default should have pg_temp implicitly first, but only for tables
select * from whereami;
@@ -248,11 +248,11 @@ drop table temp_inh_oncommit_test;
-- Function creation
begin;
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
prepare transaction 'twophase_func';
-- Function drop
create function pg_temp.twophase_func() returns void as
- $$ select '2pc_func'::text $$ language sql;
+ $$ select '2pc_func'::text $$ LANGUAGE SQLTEST;
begin;
drop function pg_temp.twophase_func();
prepare transaction 'twophase_func';
diff --git a/src/test/regress/sql/transactions.sql b/src/test/regress/sql/transactions.sql
index bf1016489d..a7a19adcf0 100644
--- a/src/test/regress/sql/transactions.sql
+++ b/src/test/regress/sql/transactions.sql
@@ -281,7 +281,7 @@ COMMIT;
--
select * from xacttest;
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' stable;
begin;
@@ -290,7 +290,7 @@ select * from xacttest;
rollback;
-- But a volatile function can see the partial results of the calling query
-create or replace function max_xacttest() returns smallint language sql as
+create or replace function max_xacttest() returns smallint LANGUAGE SQLTEST as
'select max(a) from xacttest' volatile;
begin;
diff --git a/src/test/regress/sql/typed_table.sql b/src/test/regress/sql/typed_table.sql
index 9ef0cdfcc7..057b5bd1b6 100644
--- a/src/test/regress/sql/typed_table.sql
+++ b/src/test/regress/sql/typed_table.sql
@@ -7,7 +7,7 @@ SELECT * FROM persons;
\d persons
CREATE FUNCTION get_all_persons() RETURNS SETOF person_type
-LANGUAGE SQL
+LANGUAGE SQLTEST
AS $$
SELECT * FROM persons;
$$;
@@ -57,7 +57,7 @@ CREATE TYPE person_type AS (id int, name text);
CREATE TABLE persons OF person_type;
INSERT INTO persons VALUES (1, 'test');
-CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQL AS $$ SELECT length($1.name) $$;
+CREATE FUNCTION namelen(person_type) RETURNS int LANGUAGE SQLTEST AS $$ SELECT length($1.name) $$;
SELECT id, namelen(persons) FROM persons;
CREATE TABLE persons2 OF person_type (
diff --git a/src/test/regress/sql/updatable_views.sql b/src/test/regress/sql/updatable_views.sql
index 09328e582b..47073f1925 100644
--- a/src/test/regress/sql/updatable_views.sql
+++ b/src/test/regress/sql/updatable_views.sql
@@ -394,7 +394,7 @@ INSERT INTO base_tbl SELECT i, 'Row ' || i FROM generate_series(-2, 2) g(i);
CREATE VIEW rw_view1 AS SELECT b AS bb, a AS aa FROM base_tbl;
CREATE FUNCTION rw_view1_aa(x rw_view1)
- RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sql;
+ RETURNS int AS $$ SELECT x.aa $$ LANGUAGE sqltest;
UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2
RETURNING rw_view1_aa(v), v.bb;
diff --git a/src/test/regress/sql/vacuum.sql b/src/test/regress/sql/vacuum.sql
index 93fd258fc0..bd67b67c2a 100644
--- a/src/test/regress/sql/vacuum.sql
+++ b/src/test/regress/sql/vacuum.sql
@@ -46,9 +46,9 @@ CREATE TABLE vaccluster (i INT PRIMARY KEY);
ALTER TABLE vaccluster CLUSTER ON vaccluster_pkey;
CLUSTER vaccluster;
-CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQL
+CREATE FUNCTION do_analyze() RETURNS VOID VOLATILE LANGUAGE SQLTEST
AS 'ANALYZE pg_am';
-CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQL
+CREATE FUNCTION wrap_do_analyze(c INT) RETURNS INT IMMUTABLE LANGUAGE SQLTEST
AS 'SELECT $1 FROM do_analyze()';
CREATE INDEX ON vaccluster(wrap_do_analyze(i));
INSERT INTO vaccluster VALUES (1), (2);
diff --git a/src/test/regress/sql/window.sql b/src/test/regress/sql/window.sql
index eae5fa6017..cfcd942488 100644
--- a/src/test/regress/sql/window.sql
+++ b/src/test/regress/sql/window.sql
@@ -982,15 +982,15 @@ SELECT nth_value_def(ten) OVER (PARTITION BY four), ten, four
CREATE FUNCTION logging_sfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '*' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_msfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT COALESCE($1, '') || '+' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE FUNCTION logging_minvfunc_nonstrict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL IMMUTABLE;
+LANGUAGE SQLTEST IMMUTABLE;
CREATE AGGREGATE logging_agg_nonstrict (anyelement)
(
@@ -1014,15 +1014,15 @@ CREATE AGGREGATE logging_agg_nonstrict_initcond (anyelement)
CREATE FUNCTION logging_sfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '*' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_msfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '+' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE FUNCTION logging_minvfunc_strict(text, anyelement) RETURNS text AS
$$ SELECT $1 || '-' || quote_nullable($2) $$
-LANGUAGE SQL STRICT IMMUTABLE;
+LANGUAGE SQLTEST STRICT IMMUTABLE;
CREATE AGGREGATE logging_agg_strict (text)
(
@@ -1134,7 +1134,7 @@ ORDER BY i;
CREATE FUNCTION sum_int_randrestart_minvfunc(int4, int4) RETURNS int4 AS
$$ SELECT CASE WHEN random() < 0.2 THEN NULL ELSE $1 - $2 END $$
-LANGUAGE SQL STRICT;
+LANGUAGE SQLTEST STRICT;
CREATE AGGREGATE sum_int_randomrestart (int4)
(
@@ -1324,7 +1324,7 @@ AS $$
SELECT array_agg(s) OVER w
FROM generate_series(1,5) s
WINDOW w AS (ORDER BY s ROWS BETWEEN CURRENT ROW AND GROUP_SIZE FOLLOWING)
-$$ LANGUAGE SQL STABLE;
+$$ LANGUAGE SQLTEST STABLE;
EXPLAIN (costs off) SELECT * FROM pg_temp.f(2);
SELECT * FROM pg_temp.f(2);
diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl
index 04635e93e9..94ae42f05d 100644
--- a/src/test/subscription/t/001_rep_changes.pl
+++ b/src/test/subscription/t/001_rep_changes.pl
@@ -19,7 +19,7 @@ $node_subscriber->start;
$node_publisher->safe_psql(
'postgres',
"CREATE FUNCTION public.pg_get_replica_identity_index(int)
- RETURNS regclass LANGUAGE sql AS 'SELECT 1/0'"); # shall not call
+ RETURNS regclass LANGUAGE sqltest AS 'SELECT 1/0'"); # shall not call
$node_publisher->safe_psql('postgres',
"CREATE TABLE tab_notrep AS SELECT generate_series(1,10) AS a");
$node_publisher->safe_psql('postgres',
@@ -89,7 +89,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Also wait for initial table sync to finish
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
@@ -429,7 +429,7 @@ $node_publisher->poll_query_until('postgres',
$node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub_renamed");
$result = $node_subscriber->safe_psql('postgres',
- "SELECT count(*) FROM pg_subscription");
+ "SELECT count(*) FROM pg_sub");
is($result, qq(0), 'check subscription was dropped on subscriber');
$result = $node_publisher->safe_psql('postgres',
@@ -437,7 +437,7 @@ $result = $node_publisher->safe_psql('postgres',
is($result, qq(0), 'check replication slot was dropped on publisher');
$result = $node_subscriber->safe_psql('postgres',
- "SELECT count(*) FROM pg_subscription_rel");
+ "SELECT count(*) FROM pg_sub_rel");
is($result, qq(0),
'check subscription relation status was dropped on subscriber');
diff --git a/src/test/subscription/t/002_types.pl b/src/test/subscription/t/002_types.pl
index aedcab2fbc..c25cc34a2c 100644
--- a/src/test/subscription/t/002_types.pl
+++ b/src/test/subscription/t/002_types.pl
@@ -93,7 +93,7 @@ my $ddl = qq(
);
SET check_function_bodies=off;
- CREATE FUNCTION public.monot_incr(int) RETURNS bool LANGUAGE sql
+ CREATE FUNCTION public.monot_incr(int) RETURNS bool LANGUAGE sqltest
AS ' select \$1 > max(a) from public.tst_dom_constr; ';
CREATE DOMAIN monot_int AS int CHECK (monot_incr(VALUE));
CREATE TABLE public.tst_dom_constr (a monot_int););
@@ -115,7 +115,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Wait for initial sync to finish as well
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/004_sync.pl b/src/test/subscription/t/004_sync.pl
index e111ab9181..1d735073fc 100644
--- a/src/test/subscription/t/004_sync.pl
+++ b/src/test/subscription/t/004_sync.pl
@@ -40,7 +40,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Also wait for initial table sync to finish
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
@@ -60,7 +60,7 @@ $node_subscriber->safe_psql('postgres',
);
# but it will be stuck on data copy as it will fail on constraint
-my $started_query = "SELECT srsubstate = 'd' FROM pg_subscription_rel;";
+my $started_query = "SELECT srsubstate = 'd' FROM pg_sub_rel;";
$node_subscriber->poll_query_until('postgres', $started_query)
or die "Timed out while waiting for subscriber to start sync";
@@ -83,7 +83,7 @@ $node_subscriber->safe_psql('postgres',
# wait for it to start
$node_subscriber->poll_query_until('postgres',
- "SELECT pid IS NOT NULL FROM pg_stat_subscription WHERE subname = 'tap_sub2' AND relid IS NULL"
+ "SELECT pid IS NOT NULL FROM pg_stat_sub WHERE subname = 'tap_sub2' AND relid IS NULL"
) or die "Timed out while waiting for subscriber to start";
# and drop both subscriptions
@@ -92,7 +92,7 @@ $node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub2");
# check subscriptions are removed
$result = $node_subscriber->safe_psql('postgres',
- "SELECT count(*) FROM pg_subscription");
+ "SELECT count(*) FROM pg_sub");
is($result, qq(0), 'second and third sub are dropped');
# remove the conflicting data
diff --git a/src/test/subscription/t/005_encoding.pl b/src/test/subscription/t/005_encoding.pl
index aec7a17a78..f62ac885a7 100644
--- a/src/test/subscription/t/005_encoding.pl
+++ b/src/test/subscription/t/005_encoding.pl
@@ -33,7 +33,7 @@ $node_publisher->wait_for_catchup('mysub');
# Wait for initial sync to finish as well
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/006_rewrite.pl b/src/test/subscription/t/006_rewrite.pl
index c6cda10a19..c1d8058f70 100644
--- a/src/test/subscription/t/006_rewrite.pl
+++ b/src/test/subscription/t/006_rewrite.pl
@@ -29,7 +29,7 @@ $node_publisher->wait_for_catchup('mysub');
# Wait for initial sync to finish as well
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/008_diff_schema.pl b/src/test/subscription/t/008_diff_schema.pl
index 963334ed89..cdcff2d695 100644
--- a/src/test/subscription/t/008_diff_schema.pl
+++ b/src/test/subscription/t/008_diff_schema.pl
@@ -39,7 +39,7 @@ $node_publisher->wait_for_catchup('tap_sub');
# Also wait for initial table sync to finish
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/010_truncate.pl b/src/test/subscription/t/010_truncate.pl
index be2c0bdc35..ac46e28400 100644
--- a/src/test/subscription/t/010_truncate.pl
+++ b/src/test/subscription/t/010_truncate.pl
@@ -63,7 +63,7 @@ $node_subscriber->safe_psql('postgres',
# Wait for initial sync of all subscriptions
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/011_generated.pl b/src/test/subscription/t/011_generated.pl
index f35d1cba4c..08bc828625 100644
--- a/src/test/subscription/t/011_generated.pl
+++ b/src/test/subscription/t/011_generated.pl
@@ -38,7 +38,7 @@ $node_subscriber->safe_psql('postgres',
# Wait for initial sync of all subscriptions
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/013_partition.pl b/src/test/subscription/t/013_partition.pl
index a04c03a7e2..27c7300ebd 100644
--- a/src/test/subscription/t/013_partition.pl
+++ b/src/test/subscription/t/013_partition.pl
@@ -89,7 +89,7 @@ $node_subscriber2->safe_psql('postgres',
# Wait for initial sync of all subscriptions
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber1->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
$node_subscriber2->poll_query_until('postgres', $synced_query)
diff --git a/src/test/subscription/t/014_binary.pl b/src/test/subscription/t/014_binary.pl
index 36a2f58e17..d1cc362e3a 100644
--- a/src/test/subscription/t/014_binary.pl
+++ b/src/test/subscription/t/014_binary.pl
@@ -45,7 +45,7 @@ $node_subscriber->safe_psql('postgres',
# Ensure nodes are in sync with each other
$node_publisher->wait_for_catchup('tsub');
$node_subscriber->poll_query_until('postgres',
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('s', 'r');"
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('s', 'r');"
) or die "Timed out while waiting for subscriber to synchronize data";
# Insert some content and make sure it's replicated across
diff --git a/src/test/subscription/t/015_stream.pl b/src/test/subscription/t/015_stream.pl
index 1b0e6fb9fb..9060e2e8f5 100644
--- a/src/test/subscription/t/015_stream.pl
+++ b/src/test/subscription/t/015_stream.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/016_stream_subxact.pl b/src/test/subscription/t/016_stream_subxact.pl
index b6a2d10e91..e9fa91ec2e 100644
--- a/src/test/subscription/t/016_stream_subxact.pl
+++ b/src/test/subscription/t/016_stream_subxact.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/017_stream_ddl.pl b/src/test/subscription/t/017_stream_ddl.pl
index be7d7d74e3..e8da520aa7 100644
--- a/src/test/subscription/t/017_stream_ddl.pl
+++ b/src/test/subscription/t/017_stream_ddl.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/018_stream_subxact_abort.pl b/src/test/subscription/t/018_stream_subxact_abort.pl
index ddf0621558..9a336ec1c8 100644
--- a/src/test/subscription/t/018_stream_subxact_abort.pl
+++ b/src/test/subscription/t/018_stream_subxact_abort.pl
@@ -38,7 +38,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
index 33e42edfef..a1c1c05785 100644
--- a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
+++ b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl
@@ -39,7 +39,7 @@ $node_publisher->wait_for_catchup($appname);
# Also wait for initial table sync to finish
my $synced_query =
-"SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+"SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_subscriber->poll_query_until('postgres', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/test/subscription/t/100_bugs.pl b/src/test/subscription/t/100_bugs.pl
index d1e407aacb..90f8f22cb5 100644
--- a/src/test/subscription/t/100_bugs.pl
+++ b/src/test/subscription/t/100_bugs.pl
@@ -30,7 +30,7 @@ $node_publisher->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int)");
$node_publisher->safe_psql('postgres',
- "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'"
+ "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQLTEST AS 'select x * 2'"
);
# an index with a predicate that lends itself to constant expressions
@@ -43,7 +43,7 @@ $node_subscriber->safe_psql('postgres',
"CREATE TABLE tab1 (a int PRIMARY KEY, b int)");
$node_subscriber->safe_psql('postgres',
- "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQL AS 'select x * 2'"
+ "CREATE FUNCTION double(x int) RETURNS int IMMUTABLE LANGUAGE SQLTEST AS 'select x * 2'"
);
$node_subscriber->safe_psql('postgres',
@@ -145,7 +145,7 @@ $node_twoways->safe_psql(
# XXX maybe this should be integrated in wait_for_catchup() itself.
$node_twoways->wait_for_catchup('testsub');
my $synced_query =
- "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r', 's');";
+ "SELECT count(1) = 0 FROM pg_sub_rel WHERE srsubstate NOT IN ('r', 's');";
$node_twoways->poll_query_until('d2', $synced_query)
or die "Timed out while waiting for subscriber to synchronize data";
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 266098e193..3edf16e25e 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -278,9 +278,9 @@ sub mangle_plpython3
foreach my $test (@$tests)
{
local $/ = undef;
- foreach my $dir ('sql', 'expected')
+ foreach my $dir ('sqltest', 'expected')
{
- my $extension = ($dir eq 'sql' ? 'sql' : 'out');
+ my $extension = ($dir eq 'sqltest' ? 'sqltest' : 'out');
my @files =
glob("$dir/$test.$extension $dir/${test}_[0-9].$extension");
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 1d540fe489..853b17a275 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -747,8 +747,8 @@ FormData_pg_sequence_data
FormData_pg_shdepend
FormData_pg_statistic
FormData_pg_statistic_ext
-FormData_pg_subscription
-FormData_pg_subscription_rel
+FormData_pg_sub
+FormData_pg_sub_rel
FormData_pg_tablespace
FormData_pg_transform
FormData_pg_trigger
@@ -803,8 +803,8 @@ Form_pg_sequence_data
Form_pg_shdepend
Form_pg_statistic
Form_pg_statistic_ext
-Form_pg_subscription
-Form_pg_subscription_rel
+Form_pg_sub
+Form_pg_sub_rel
Form_pg_tablespace
Form_pg_transform
Form_pg_trigger
diff --git a/src/tutorial/funcs.source b/src/tutorial/funcs.source
index 542b5c81ec..2f2c38fac2 100644
--- a/src/tutorial/funcs.source
+++ b/src/tutorial/funcs.source
@@ -22,7 +22,7 @@
-- returns 1
CREATE FUNCTION one() RETURNS integer
- AS 'SELECT 1 as ONE' LANGUAGE SQL;
+ AS 'SELECT 1 as ONE' LANGUAGE SQLTEST;
--
-- functions can be used in any expressions (eg. in the target list or
@@ -35,7 +35,7 @@ SELECT one() AS answer;
-- function returns the sum of its two arguments:
CREATE FUNCTION add_em(integer, integer) RETURNS integer
- AS 'SELECT $1 + $2' LANGUAGE SQL;
+ AS 'SELECT $1 + $2' LANGUAGE SQLTEST;
SELECT add_em(1, 2) AS answer;
@@ -65,7 +65,7 @@ INSERT INTO EMP VALUES ('Ginger', 4800, 30, '(2,4)');
-- double_salary takes a tuple of the EMP table
CREATE FUNCTION double_salary(EMP) RETURNS integer
- AS 'SELECT $1.salary * 2 AS salary' LANGUAGE SQL;
+ AS 'SELECT $1.salary * 2 AS salary' LANGUAGE SQLTEST;
SELECT name, double_salary(EMP) AS dream
FROM EMP
@@ -80,7 +80,7 @@ CREATE FUNCTION new_emp() RETURNS EMP
1000 AS salary,
25 AS age,
''(2,2)''::point AS cubicle'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
-- you can then project a column out of resulting the tuple by using the
-- "function notation" for projection columns. (ie. bar(foo) is equivalent
@@ -91,7 +91,7 @@ SELECT name(new_emp()) AS nobody;
-- let's try one more function that returns tuples
CREATE FUNCTION high_pay() RETURNS setof EMP
AS 'SELECT * FROM EMP where salary > 1500'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT name(high_pay()) AS overpaid;
@@ -109,7 +109,7 @@ SELECT * FROM EMP;
CREATE FUNCTION clean_EMP () RETURNS integer
AS 'DELETE FROM EMP WHERE EMP.salary <= 0;
SELECT 1 AS ignore_this'
- LANGUAGE SQL;
+ LANGUAGE SQLTEST;
SELECT clean_EMP();
On Thu, Feb 11, 2021 at 08:16:30PM +0300, Anastasia Lubennikova wrote:
On 28.01.2021 09:55, Noah Misch wrote:
On Wed, Jan 27, 2021 at 07:32:42PM +0300, Anastasia Lubennikova wrote:
On 27.01.2021 14:21, Noah Misch wrote:
On Mon, Jan 25, 2021 at 10:14:43PM +0300, Anastasia Lubennikova wrote:
1) Could you please clarify, what do you mean by REVOKE failures?
I tried following example:
Start 9.6 cluster.
REVOKE ALL ON function pg_switch_xlog() FROM public;
REVOKE ALL ON function pg_switch_xlog() FROM backup;The upgrade to the current master passes with and without patch.
It seems that current implementation of pg_upgrade doesn't take into account
revoke ACLs.I think you can observe it by adding "revoke all on function
pg_stat_get_subscription from public;" to test_add_acl_to_catalog_objects.sql
and then rerunning your test script. pg_dump will reproduce that REVOKE,
which would fail if postgresql.org had removed that function. That's fine, so
long as a comment mentions the limitation.
I've now tested exactly that. It didn't cause a test script failure, because
pg_upgrade_ACL_test.sh runs "pg_upgrade --check" but does not run the final
pg_upgrade (without --check). The failure happens only without --check. I've
attached a modified version of your test script that reproduces the problem.
It uses a different function, timenow(), so the test does not depend on
test_rename_catalog_objects_v14. The attached script fails with this output:
===
Consult the last few lines of "pg_upgrade_dump_13325.log" for
the probable cause of the failure.
Failure, exiting
===
That log file contains:
===
command: "/tmp/workdir/postgresql_bin_test_new/bin/pg_dump" --host /home/nm/src/pg/backbranch/extra --port 50432 --username nm --schema-only --quote-all-identifiers --binary-upgrade --format=custom --file="pg_upgrade_dump_13325.custom" 'dbname=postgres' >> "pg_upgrade_dump_13325.log" 2>&1
command: "/tmp/workdir/postgresql_bin_test_new/bin/pg_restore" --host /home/nm/src/pg/backbranch/extra --port 50432 --username nm --clean --create --exit-on-error --verbose --dbname template1 "pg_upgrade_dump_13325.custom" >> "pg_upgrade_dump_13325.log" 2>&1
pg_restore: connecting to database for restore
pg_restore: dropping DATABASE PROPERTIES postgres
pg_restore: dropping DATABASE postgres
pg_restore: creating DATABASE "postgres"
pg_restore: connecting to new database "postgres"
pg_restore: creating COMMENT "DATABASE "postgres""
pg_restore: creating DATABASE PROPERTIES "postgres"
pg_restore: connecting to new database "postgres"
pg_restore: creating pg_largeobject "pg_largeobject"
pg_restore: creating ACL "pg_catalog.FUNCTION "timenow"()"
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 3047; 0 0 ACL FUNCTION "timenow"() nm
pg_restore: error: could not execute query: ERROR: function pg_catalog.timenow() does not exist
Command was: REVOKE ALL ON FUNCTION "pg_catalog"."timenow"() FROM PUBLIC;
===
In the updated patch, I implemented generation of both GRANT ALL and REVOKE
ALL for problematic objects. If I understand it correctly, these calls will
clean object's ACL completely. And I see no harm in doing this, because the
objects don't exist in the new cluster anyway.
Here's fix_system_objects_ACL.sql with your v14 test script:
===
\connect postgres
GRANT ALL ON function pg_catalog.pg_stat_get_subscription(pg_catalog.oid) TO "backup" ;
REVOKE ALL ON function pg_catalog.pg_stat_get_subscription(pg_catalog.oid) FROM "backup" ;
GRANT ALL ON pg_catalog.pg_stat_subscription TO "backup" ;
REVOKE ALL ON pg_catalog.pg_stat_subscription FROM "backup" ;
GRANT ALL ON pg_catalog.pg_subscription TO "backup","test" ;
REVOKE ALL ON pg_catalog.pg_subscription FROM "backup","test" ;
GRANT ALL (subenabled) ON pg_catalog.pg_subscription TO "backup" ;
REVOKE ALL (subenabled) ON pg_catalog.pg_subscription FROM "backup" ;
===
Considering the REVOKE statements, those new GRANT statements have no effect.
To prevent the final pg_upgrade failure, fix_system_objects_ACL.sql would need
"GRANT ALL ON FUNCTION pg_catalog.pg_stat_get_subscription(pg_catalog.oid) TO
PUBLIC;". Alternately, again, I don't mind if this case continues to fail, so
long as a comment mentions the limitation. How would you like to proceed?
One other thing:
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index 43fc297eb6..f2d593f574 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c
...
+check_for_changed_signatures(void)
+{
...
+ /* + * + * AclInfo array is sorted by obj_ident. This allows us to compare + * AclInfo entries with the query result above efficiently. + */ + for (aclnum = 0; aclnum < dbinfo->non_def_acl_arr.nacls; aclnum++) + { + AclInfo *aclinfo = &dbinfo->non_def_acl_arr.aclinfos[aclnum]; + bool report = false; + + while (objnum < ntups) + { + int ret; + + ret = strcmp(aclinfo->obj_ident, + PQgetvalue(res, objnum, i_obj_ident));
I think this should check obj_type in addition to obj_ident. Otherwise, it
can't distinguish a relation from a type of the same name.
nm
Attachments:
This patch has been marked Waiting on Author since early March, with the thread
stalled since then. I'm marking this CF entry Returned with Feedback, please
feel free to resubmit it if/when a new version of the patch is available.
--
Daniel Gustafsson https://vmware.com/