简体   繁体   中英

Does pg_restore or pg_dump add statements to the schema?

I have a database that I've been using since a while now. I improved its schema a bit and wanted the compare the differences between the new schema and the old schema and so I dumped both schemas and did a diff. In the old schema, I'm seeing some 'OPERATOR FAMILY' statements that are not visible in the new schema. If it makes any difference, these 'OPERATOR FAMILY' statements relate to the tsearch2 contrib package for PostgreSQL (eg: 'CREATE OPERATOR FAMILY gin_tsvector_ops', etc). The 'OPERATOR CLASS' statements relating to tsearch2 operators are present in both the schemas. Also all of the added 'OPERATOR FAMILY' statements are followed by 'OPERATOR CLASS' statements of the same name, though the 'OPERATOR CLASS' statements are found in both the schemas.

Where it gets really strange is that when I create a database with the new schema, dump its schema using pg_dump, restore it in another database using pg_restore and then dump it again - the 'OPERATOR FAMILY' statements show up! I grep'd the contrib directory but I can't find any 'CREATE OPERATOR FAMILY' statements.

Anyone had a similar experience? Any ideas what might be introducing those statements?

In response to your comment, I would guess the PostgreSQL version migration caused this. In 7.2 tsearch2 was an external contrib module, but in PostgreSQL 8.3 it was integrated into core. So those missing OPERATOR FAMILYs probably come from PostgreSQL 8.3's pg_catalog instead of your own schema.

But I think you can fix it up using the contrib/uninstall_tsearch2.sql script (usually in /usr/share/postgresql-VER/contrib/ ) to uninstall and then re-install with the contrib/tsearch2.sql script. Ignore any errors you get, those should be safe, since you can't drop types that you're currently using in your tables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM