Extension is not relocatable
madisonleavo opened this issue · 5 comments
SQL needs to reference @extschema@ to be relocatable. Need to update references to table zson_dict in C. Currently zson assumes all calls are made within the same schema.
@madisonleavo thank you for creating this issue. Truth to be told, this is my very first PostgreSQL extension and I'm not quite sure how to make an extension relocatable on a C side. As I understand @extschema@ works only in a script file during extension installation. A piece of advice regarding this matter or maybe a reference to an extension that handles relocation properly will be much appreciated.
Also if it's not too much trouble could you please provide exact steps of how you found this issue. I have an idea how to do it but more tests I include in the next release the better.
Ah, ok. I said 'broken' because your .CONTROL file had relocatable=TRUE. In that case, we can probably borrow the technique from another extension: pg_partman.
Looks like he's searching for the schema name based on the extension name, then saving that as local variable and referencing in any queries.
SELECT n.nspname FROM pg_catalog.pg_extension e JOIN pg_catalog.pg_namespace n ON e.extnamespace = n.oid WHERE extname = 'pg_partman';
https://github.com/keithf4/pg_partman/blob/master/src/pg_partman_bgw.c
Otherwise, I'm not sure what all is involved with making an extension truly relocatable. All I wanted was to separate out zson from my other 'data' schema.