pgFormatter::CGI(3)

πŸ’… pgFormatter::CGI(3) β€” CGI-BIN but make it cute πŸ’…

okay so bestie, welcome to the User Contributed Perl Documentation page for pgFormatter::CGI, and it's literally the implementation of a CGI-BIN script to format SQL queries. yes, we're doing Perl CGI in this economy and it absolutely slays. 🫢


πŸ’– NAME πŸ’–

pgFormatter::CGI β€” the implementation of a CGI-BIN script to format SQL queries. that's the whole name-and-what-it-does moment, bestie. πŸ’…


πŸ¦‹ VERSION πŸ¦‹

Version 5.11. that's the version, periodt. πŸ‘‘


✨ SYNOPSIS ✨

This module is called by the pg_format program when it detects it is run in a CGI environment. In such case all control over flow is passed to this module by calling:

           my $program = pgFormatter::CGI->new();
           $program->run()

no cap, that's the whole entry point vibe. πŸŽ€


πŸŽ€ FUNCTIONS πŸŽ€

🌱 new

Object constructor, calls set_config method to set default values for various parameters. it's giving setup era. 🧚

🚦 run

Route to the right handler based on what sort of data we receive. literally the traffic director of this whole situation. πŸ›£οΈ

🌸 run_webpage

Wraps all work related to generating html page.

It calls set of functions to get CGI object, receive parameters from request, sanitize them, beautify query (if provided) and print ghtml. yes bestie, ghtml is right there in the original and we're keeping it. πŸ’…

🌈 run_api

Wraps all work related to generating JSON response when used as API. API mode said "I'm the main character now." ✨

🫢 get_cgi

  • Creates CGI object, and sets POST size limit. πŸ›‘
  • Sets config for the page and beautifier. URLs, names of auxiliary files, configuration for pgFormatter::Beautify module. πŸŽ€
  • Loads, and returns, default CSS from __DATA__. πŸ’–
  • Gets values of parameters, and possibly uploaded file from CGI object to structures in $self. πŸ“₯
  • Get params for the API version of this service. πŸ”Œ

🧼 sanitize_params

Overrides parameter values if given values were not within acceptable ranges. it's giving boundaries, bestie. 🚧

πŸ’– beautify_query

Runs beautification on provided query, and stores new version in $self->{'content'}. glow-up for your SQL, fr fr. ✨

Outputs beautified SQL as JSON.

Outputs body of the page. two jobs, one function, we love a multitasker. πŸ’…

Outputs footer of the page. the little bow on top. πŸŽ€

😭 _load_optional_file

Helper function to try to load file. If it succeeds, it returns file content, it not, it returns empty string (instead of dying). yes, "it not" β€” we keep the typo energy, no cap. 🫢

Outputs an error message when no acceptable response is found. dramatic? maybe. necessary? absolutely. πŸ’€

Outputs page headers - both HTTP level headers, and HTML. both layers, bestie. 🧚


🌈 DATA 🌈

__DATA__ section (at the end of this file) is used to store default CSS Style, so that it will not "pollute" Perl code, and will not need to be indented. aesthetic and functional, we love to see it. πŸŽ€


πŸ‘‘ AUTHOR πŸ‘‘

pgFormatter is an original work from Gilles Darold. iconic author moment. πŸ‘‘


πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests to: https://github.com/darold/pgFormatter/issues. do it bestie, the issues page is waiting. πŸ›


Copyright 2012-2026 Gilles Darold. All rights reserved. πŸ’–


🧚 LICENSE 🧚

pgFormatter is free software distributed under the PostgreSQL Licence. πŸ“œ

A modified version of the SQL::Beautify Perl Module is embedded in pgFormatter with copyright (C) 2009 by Jonas Kramer and is published under the terms of the Artistic License 2.0. 🧚


and that's the whole page, bestie β€” it came from perl v5.42.2, dated 2026-09-04, and it's pgFormatter::CGI(3). mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from