HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Makefile issue in Creating Postgres Extension

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
makefilepostgrescreatingissueextension

Problem

My basic extension code is at location -> /Users/spartacus/Desktop/GSoC/CODE/my_extension

  • my_extension.control



# my_extension.control
comment = 'Minimal Viable Product'
default_version = '1.0'
relocatable = true

# Installation script for version 1.0
# 1.0
# my_extension--1.0.sql


  • my_extension--1.0.sql



-- my_extension--1.0.sql

-- Create necessary objects for version 1.0
CREATE TABLE my_table (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL
);

CREATE FUNCTION my_function() RETURNS void AS $$
BEGIN
-- Function logic goes here
END;


  • MakeFile



DATA = my_extension--1.0.sql

PG_CONFIG  ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)


-- cd command to navigate to the directory where your extension files are located. After connecting to that location, executing the make command throws this error:

make: Nothing to be done for 'all'

-- After executing make install:

  • /bin/sh /opt/homebrew/lib/postgresql/pgxs/src/makefiles/../../config/install-sh -c -d '/opt/homebrew/share/postgresql/contrib'



  • /usr/bin/install -c -m 644 .//my_extension--1.0.sql '/opt/homebrew/share/postgresql/contrib/'



-- Running psql;
Then after executing CREATE EXTENSION my_extension; This error occurs:

  • ERROR: extension "my_extension" is not available



  • DETAIL: Could not open extension control file "/Applications/Postgres.app/Contents/Versions/15/share/postgresql/extension/my_extension.control": No such file or directory.



  • HINT: The extension must first be installed on the system where PostgreSQL is running.



How to solve this issue?

Solution

Your Makefile is lacking the entry
EXTENSION = my_extension


That's why make install doesn't copy the *.control file, and that's why CREATE EXTENSION fails.

Context

StackExchange Database Administrators Q#328624, answer score: 2

Revisions (0)

No revisions yet.