Fix case of function language for PostgreSQL 9.2+ #120

Closed
wants to merge 1 commit into
from

Projects

None yet

1 participant

@millerdev

Language names are case-sensitive in PostgreSQL 9.2+

Old upgrade packages have the wrong case, so upgrades on PG9.2+ require some gymnastics. First create a new language:

INSERT INTO pg_catalog.pg_language (
    lanname, lanowner, lanispl, lanpltrusted,
    lanplcallfoid, laninline, lanvalidator
) VALUES ('SQL', 10, false, true, 0, 0, 2248);

Next upgrade the database using the updater tool. Then re-create all functions that depend on the SQL language, but replace "LANGUAGE 'SQL'" with "LANGUAGE 'sql'". You can find them with this query:

SELECT pg_proc.proname, lanname
FROM pg_catalog.pg_proc
    JOIN pg_catalog.pg_language
        ON pg_proc.prolang = pg_language.oid
WHERE lanname = 'SQL';

Finally, when there are no more functions that depend on the 'SQL' language you can delete it:

DELETE FROM pg_catalog.pg_language
WHERE lanname = 'SQL';
@millerdev millerdev Fix case of function language for PostgreSQL 9.2+
Language names are case-sensitive in PostgreSQL 9.2+.

Old upgrade packages have the wrong case, so upgrades on PG9.2+ require some gymnastics. First create a new language:

    INSERT INTO pg_catalog.pg_language (
        lanname, lanowner, lanispl, lanpltrusted,
        lanplcallfoid, laninline, lanvalidator
    ) VALUES ('SQL', 10, false, true, 0, 0, 2248);

Next upgrade the database using the updater tool. Then re-create all functions that depend on the SQL language, but replace "LANGUAGE 'SQL'" with "LANGUAGE 'sql'". You can find them with this query:

    SELECT pg_proc.proname, lanname
    FROM pg_catalog.pg_proc
      JOIN pg_catalog.pg_language
          ON pg_proc.prolang = pg_language.oid
    WHERE lanname = 'SQL';

Finally, when there are no more functions that depend on the 'SQL' language you can delete it:

    DELETE FROM pg_catalog.pg_language
    WHERE lanname = 'SQL';
52fd850
@millerdev

Ah, looks like this is a duplicate of #119

@millerdev millerdev closed this Feb 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment