Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres. Error installing my own extension

Tags:

postgresql

I'm trying to install a custom small extension for Postgres just for testing, but I can't do it.

My steps: 1.- Create the *.sql file (hola.sql):

CREATE OR REPLACE FUNCTION di_hola() 
RETURNS void AS 
$BODY$
BEGIN
RAISE NOTICE 'Hola';
END; 
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION di_hola()
  OWNER TO postgres;

2.- Create control file (hola.control):

# hola extension
comment = 'Funcion para decir hola'
default_version = '1.0'
relocatable = false

3.- Makefile:

EXTENSION = hola
DATA = hola.sql

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

4.- Install it (in my case /usr/share/postgresql/10/extension)

sudo make USE_PGXS=1 install

5.- From psql (psql -U postgres -h localhost -W)

postgres=# create extension hola;
ERROR:  extension "hola" has no installation script nor update path for version "1.0"

I can't find many information about this error. The files are properly installed in /usr/share/postgresql/10/extension

I have Postgres 10 under Linux Mint.

Thank you

like image 357
exodehm Avatar asked Apr 21 '26 14:04

exodehm


1 Answers

The SQL script for version 1.0 must be called

hola--1.0.sql
like image 182
Laurenz Albe Avatar answered Apr 23 '26 06:04

Laurenz Albe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!