Comments (5)
Regarding the first point: KNOWN_LANGS is a replacement for the pg_pltemplate catalog which was dropped in PG 13. The catalog only listed PL's that were available in the core distribution. As per https://www.postgresql.org/docs/current/external-pl.html, PL/v8 is still an externally-maintained language, so I don't think we should add it to KNOWN_LANGS. If you have PL/v8 installed, it will be handled as an extension. If that is causing some issues, please describe them so that they can be looked into.
from pyrseas.
To repeat the problem:
test database
CREATE EXTENSION IF NOT EXISTS plv8;
CREATE FUNCTION public.test() RETURNS integer
LANGUAGE plv8
AS $$return 1$$;
dbtoyaml
dbtoyaml -o test.yml test
test.yml
extension plpgsql:
description: PL/pgSQL procedural language
owner: postgres
schema: pg_catalog
version: '1.0'
extension plv8:
description: PL/JavaScript (v8) trusted procedural language
owner: billuser
schema: pg_catalog
version: 3.0alpha
schema public:
description: standard public schema
function test():
language: plv8
owner: billuser
returns: integer
source: |-
return 1
owner: postgres
privileges:
- PUBLIC:
- all
- postgres:
- all
create new database test_new (does not contain plv8 extension) and yamltodb
yamltodb -1 -o create.sql test_new test.yml
error
Traceback (most recent call last):
File "/usr/local/bin/yamltodb", line 33, in <module>
sys.exit(load_entry_point('Pyrseas==0.10.0', 'console_scripts', 'yamltodb')())
File "/usr/local/lib/python3.9/dist-packages/Pyrseas-0.10.0-py3.9.egg/pyrseas/yamltodb.py", line 49, in main
stmts = db.diff_map(inmap)
File "/usr/local/lib/python3.9/dist-packages/Pyrseas-0.10.0-py3.9.egg/pyrseas/database.py", line 526, in diff_map
self.from_map(input_map)
File "/usr/local/lib/python3.9/dist-packages/Pyrseas-0.10.0-py3.9.egg/pyrseas/database.py", line 397, in from_map
self._link_refs(self.ndb)
File "/usr/local/lib/python3.9/dist-packages/Pyrseas-0.10.0-py3.9.egg/pyrseas/database.py", line 218, in _link_refs
db.languages.link_refs(db.functions, langs)
File "/usr/local/lib/python3.9/dist-packages/Pyrseas-0.10.0-py3.9.egg/pyrseas/dbobject/language.py", line 143, in link_refs
raise exc
File "/usr/local/lib/python3.9/dist-packages/Pyrseas-0.10.0-py3.9.egg/pyrseas/dbobject/language.py", line 139, in link_refs
language = self[(func.language)]
KeyError: 'plv8'
from pyrseas.
I've managed to reproduce the problem using plr
(which is available as a package on Debian). This appears to be another one of those "special-casing of extensions" problems we recently discussed in #248. Have to dig deeper.
from pyrseas.
I've been experimenting with some ways to deal with externally managed languages. Part of the problem stems from what @dvarrazzo has pointed out elsewhere various times, i.e., the special-case extension stuff in catalog queries. In this case, in dbobject/language.py
the query has the following clause:
AND l.oid NOT IN (
SELECT objid FROM pg_depend WHERE deptype = 'e'
AND classid = 'pg_language'::regclass)
If I remove that, in a database where both plpgsql and plr are present, dbtoyaml
prints both extensions and both languages in the YAML output.
I believe we need to print the language plr
section in order for the inbound mapping to work properly. Otherwise, yamltodb
has no way of knowing that a particular external language needs to be present in the target (unless, of course, we parse extension <lang>
and we maintain a special list of externally maintained languages that we're willing to support).
So the interim plan is as follows (until we do something more comprehensive):
- Remove the special-case clause shown above.
- On the
to_map
side, exclude the core maintained languages from the YAML output, most likely by using the already defined KNOWN_LANGS, while allowing the externally maintained languages to be shown. - On the
to_sql
side, the presence of alanguage x
on the input YAML already allows a function in that language to be processed properly. However, it also causes aCREATE LANGUAGE x
to be emitted and that will have to be suppressed.
Daniele, your review/comments will be appreciated.
from pyrseas.
Ok, I have made the changes discussed above and I'll be submitting the fix shortly. @albrov please test with plv8 (I tested with plr because it was more convenient for me). @dvarrazzo I've removed tests/dbobject/test_language.py
because the only thing left was a test (which you created) for bug #103 for plpython3u
which as I see it is no longer in use. I've also essentially nulled-out the code for Language.create
(and eliminated the special case in Language.drop
) because CREATE/DROP LANGUAGE should all be occurring as a result of CREATE/DROP EXTENSION, regardless of whether they're core- or externally maintained.
from pyrseas.
Related Issues (20)
- ALTER SEQUENCE OWNER comes before CREATE TABLE HOT 3
- SSL Connection to remote database HOT 3
- datacopy CSV with null trailing columns not importing with -u HOT 7
- CREATE EXTENSION statements in the change script HOT 5
- [Contribution] Docker support HOT 2
- Sequences processing doesn't skip schemas defined with '-N' option. HOT 3
- dbtoyaml fails when dealing with extension-owned triggers/functions HOT 7
- Multiline Strings (source: |2) Output Unstable HOT 5
- Enable Github Discussions HOT 2
- Fails to Install: Error: pg_config executable not found HOT 5
- Error Using dbtoyaml With Supabase Schema HOT 67
- dbtoyaml Fails When PG Password Has Spaces (Improper Escaping) HOT 1
- Convert .travis.yml to GH Actions
- Fold pgdbconn back into Pyrseas HOT 1
- Key error when converting aggregate to YAML HOT 4
- Add REFERENCING tables in trigger HOT 3
- Support columns GENERATED AS (x) STORED HOT 2
- Support --revert for tables HOT 4
- the yamltodb tool is not placing the names of schemas, tables and columns in double quotes HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyrseas.