do not use equal sign in paths in windows or make sure to use dbl quotes...

env: windows 10

so basically, when a path contains an equal sign, for example:

d:\some_folder\=some_other_folder\some_even_deeper_nested_folder\and_so_on

a command like this:

rmdir d:\some_folder\=some_other_folder\some_even_deeper_nested_folder\and_so_on

will be effectively evaluated as:

rmdir d:\some_folder

a fix? appears to be simple (notice the dbl quotes!):

rmdir "d:\some_folder\=some_other_folder\some_even_deeper_nested_folder\and_so_on"

kill pg connection

PostgreSQL 9.2 and above:

SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
  AND pid <> pg_backend_pid();

PostgreSQL 9.1 and below:

SELECT pg_terminate_backend(pg_stat_activity.procpid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
  AND procpid <> pg_backend_pid();

Logging in pgsql

edit postgresql.conf and change the following:

log_statement = 'all'
log_min_duration_statement = 0
logging_collector = on
#log_directory = 'pg_log'

make sure pg_log is available relative to the data dir

restart pgsql service

PostGIS to GeoJSON

SELECT
    row_to_json(feature_collection)
FROM (
    SELECT
        'FeatureCollection'::text as type,
        case
            when
                array_agg(feature_collection_data) is null
            then
                array_to_json(ARRAY[]::varchar[]) 
            else
                array_to_json(array_agg(feature_collection_data))
        end as features
    FROM (
        SELECT
            'Feature'::text as type,
            ST_AsGeoJSON({geomCol})::json as geometry,
            row_to_json((SELECT row FROM (SELECT {properties}) as row)) as properties
        FROM
            {table} as row_data
        WHERE
            {where}
    )  as feature_collection_data
)  as feature_collection;";

Notes:

{geomCol} - geom column to select from or geometry returning call such as ST_GeomFromText('POINT(' || lon || ' ' || lat || ')' ,4326)

{properties} - a comma separated list of columns to select from; can be aliased

{table} - a table to select from

{where} - a where clause if needed