Giter Site home page Giter Site logo

fabriziomello / pg_normalize_query Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 1.0 43 KB

PostgreSQL extension to normalize SQL statements

License: BSD 3-Clause "New" or "Revised" License

Makefile 2.54% C 97.46%
pg-stat-statements sql-query normalize parser postgres postgresql extension

pg_normalize_query's Introduction

pg_normalize_query

PostgreSQL extension to normalize SQL statements similar to pg_stat_statements.

This code was extracted from libpg_query and transformed into a PostgreSQL extension.

Supported PostgreSQL versions

The aim of the project is support as many community-supported major versions of Postgres as possible. Currently, the following versions of PostgreSQL are supported:

9.4, 9.5, 9.6, 10, 11, 12 and master (pre-13).

Installation

$ git clone https://github.com/fabriziomello/pg_normalize_query.git
$ cd pg_normalize_query
# Make sure your path includes the bin directory that contains the correct `pg_config`
$ PATH=/path/to/pg/bin:$PATH
$ USE_PGXS=1 make
$ USE_PGXS=1 make install

Tests

$ USE_PGXS=1 make installcheck

Examples

fabrizio=# CREATE EXTENSION pg_normalize_query;
CREATE EXTENSION
fabrizio=# \dx
                       List of installed extensions
        Name        | Version |   Schema   |         Description          
--------------------+---------+------------+------------------------------
 pg_normalize_query | 1.0     | public     | Normalize SQL Query
 plpgsql            | 1.0     | pg_catalog | PL/pgSQL procedural language
(2 rows)

fabrizio=# SELECT pg_normalize_query($$SELECT * FROM pg_proc WHERE proname = 'pg_normalize_query'$$);
            pg_normalize_query            
------------------------------------------
 SELECT * FROM pg_proc WHERE proname = $1
(1 row)

fabrizio=# SELECT pg_normalize_query($$SELECT oid, relname, relkind FROM pg_class WHERE relkind IN ('r', 'i') LIMIT 10$$);
                              pg_normalize_query                               
-------------------------------------------------------------------------------
 SELECT oid, relname, relkind FROM pg_class WHERE relkind IN ($1, $2) LIMIT $3
(1 row)

Please feel free to open a PR.

Authors

License

PostgreSQL server source code, used under the PostgreSQL license.
Portions Copyright (c) 1996-2020, The PostgreSQL Global Development Group
Portions Copyright (c) 1994, The Regents of the University of California

All other parts are licensed under the 3-clause BSD license, see LICENSE file for details.
Copyright (c) 2020, Fabrízio de Royes Mello [email protected]

pg_normalize_query's People

Contributors

fabriziomello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

samilekesiz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.