Gsoc08-pgscript

From PostgreSQL wiki
Jump to navigationJump to search


Project Summary

pgScript was a scripting language for pgAdmin and PostgreSQL based on a T-SQL syntax. Therefore it ran on the client side.

Project development was ceased with PgAdmin version 4.

Archived project code: https://www.postgresql.org/ftp/projects/pgFoundry/pgscript/


Detailed info

pgScript enhances PostgreSQL SQL commands with these additional features:

  • Control-of-flow language
  • Local variables
  • Random data generators

For instance:

SET @A = INTEGER(0, 10);           -- Random integer generator into @A
IF (SELECT 1 FROM table)           -- Then table exists
BEGIN
    SET @B = SELECT * FROM table;  -- Stores result of the query in @B
    INSERT INTO table VALUES (@A); -- Inserts a random integer
    PRINT @B;                      -- Prints result of the previous query
END
ELSE                               -- Else table does not exist
BEGIN
    CREATE TABLE table ( ... );    -- Regular PostgreSQL command
END

pgScript interprets the kind of script above. For more details please look at http://pgscript.projects.postgresql.org.

pgScript is (will) also integrated into pgAdmin. You can access pgScript through the Query tool in pgAdmin: see http://www.pgadmin.org for information & download.

Timeline

There are two parts in the project:

  • (07/06) Make a standalone version (program or library) of pgScript
  • (08/10) Integrate it into pgAdmin