commit 5d58c1372fa737832106919d87f68d7ad793df51 Author: anastasia 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 #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();