Skip to content

riyazwalikar/postgres-runcmd-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Runcmd - A Postgres extension that allows command execution

This is a quick and hackish way of executing commands from within a Postgres database.

Pre-reqs

You will need the header files, the extension build tools and the database cluster manager which can be setup (on Ubuntu) with

sudo apt-get install libpq-dev
sudo apt-get install postgresql-server-dev-all
sudo apt-get install postgresql-common

Compiling and Installation

From the current directory where the code is present run

  • make USE_PGXS=1
  • sudo make USE_PGXS=1 install

Then from within Postgres, run the following to setup the functions

CREATE EXTENSION runcmd;
CREATE OR REPLACE FUNCTION runcmd(TEXT) RETURNS INTEGER AS 'runcmd.so', 'pg_runcmd' LANGUAGE 'C' WITH (ISSTRICT);

Once the extension is loaded and the function is created, you can call the function like this

SELECT pg_runcmd('id');

Important note

  • This code is not complete. I created this as part of some random poking around Postgres and custom extensions.
  • If you know how to get this working, please make a pull request or open an issue!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published