Skip to content

Commit

Permalink
Merge pull request #2873 from EnterpriseDB/docs/postgis/updating-code…
Browse files Browse the repository at this point in the history
…-blocks

PostGIS: code block changes
  • Loading branch information
drothery-edb authored Jul 7, 2022
2 parents d559f26 + 068ed68 commit 5e8382c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 46 deletions.
10 changes: 5 additions & 5 deletions product_docs/docs/postgis/3.1/02_creating_extensions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ After installing PostGIS, create a PostGIS database and the extensions in each d

1. Before creating the postgis database, we recommend creating a superuser to administer the database. To create the user, navigate to the bin directory under your EDB Postgres Advanced Server installation and connect to the server with the psql client:

```text
```sql
./psql -d edb -U enterprisedb -h 127.0.0.1
```

2. Invoke the following command to create a privileged role:

```text
```sql
CREATE ROLE gisadmin LOGIN PASSWORD 'password' SUPERUSER;
```

3. Log out of psql and connect as gisadmin:

```text
```sql
edb=# \q
./psql -d edb -U gisadmin -h 127.0.0.1
```

4. Invoke the following command to create the postgis database owned by gisadmin:

```text
```sql
CREATE DATABASE postgis;
```

5. Use the `\c` command to switch to the postgis database, and use the `CREATE EXTENSION` command to create the PostGIS extensions:

```text
```sql
\c postgis
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
Expand Down
48 changes: 24 additions & 24 deletions product_docs/docs/postgis/3.1/03_upgrading_postgis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ The following example walks you through the process of upgrading PostGIS version

1. To upgrade PostGIS version 2.4.6 to PostGIS version 3.1.1 for EDB Postgres Advanced Server 9.6, assume the superuser privileges and invoke the following command:

```text
```shell
yum upgrade edb-as96-postgis-3.1.1 -y
```

2. To update extensions, switch to `enterprisedb` user, connect to the database (where you have already created extensions) with the psql client application, and execute the following commands:

```text
```sql
edb=# alter extension postgis update to '3.1.1';
WARNING: unpackaging raster
WARNING: PostGIS Raster functionality has been unpackaged
HINT: type `SELECT postgis_extensions_upgrade();` to finish the upgrade. After upgrading, if you want to drop raster, run: DROP EXTENSION postgis_raster;
ALTER EXTENSION
```

```text
```sql
edb=# alter extension address_standardizer update to '3.1.1';
ALTER EXTENSION
```

```text
```sql
edb=# SELECT postgis_extensions_upgrade();
NOTICE: Updating extension postgis_sfcgal from 2.4.6 to 3.1.1
NOTICE: Packaging extension postgis_raster
Expand Down Expand Up @@ -74,13 +74,13 @@ Step 1 - To upgrade PostGIS version 2.4.6 to 3.1.2, you need to upgrade it to 3.

1. Navigate to the bin directory of EDB Advanced Server 9.6:

```text
```shell
cd /usr/edb/as9.6/bin/
```

2. Assume the superuser privileges and invoke the following command to upgrade to PostGIS version 3.1.1:

```text
```shell
yum upgrade edb-as96-postgis-3.1.1 -y
```

Expand All @@ -89,20 +89,20 @@ Step 1 - To upgrade PostGIS version 2.4.6 to 3.1.2, you need to upgrade it to 3.

3. To update extensions, switch to `enterprisedb` user, connect to the database (where you have already created extensions) with the psql client application, and execute the following commands:

```text
```sql
edb=# alter extension postgis update to '3.1.1';
WARNING: unpackaging raster
WARNING: PostGIS Raster functionality has been unpackaged
HINT: type `SELECT postgis_extensions_upgrade();` to finish the upgrade. After upgrading, if you want to drop raster, run: DROP EXTENSION postgis_raster;
ALTER EXTENSION
```

```text
```sql
edb=# alter extension address_standardizer update to '3.1.1';
ALTER EXTENSION
```

```text
```sql
edb=# SELECT postgis_extensions_upgrade();
NOTICE: Updating extension postgis_sfcgal from 2.4.6 to 3.1.1
NOTICE: Packaging extension postgis_raster
Expand All @@ -118,13 +118,13 @@ Step 2 - Upgrade to PostGIS version 3.1.2

1. To upgrade PostGIS version 3.1.1 to 3.1.2, invoke the following command for EDB Postgres Advanced Server 9.6:

```text
```shell
yum upgrade edb-as96-postgis-3.1.2 -y
```

2. To update extensions, switch to `enterprisedb` user and execute the following commands:

```text
```sql
edb=# alter extension postgis update to '3.1.2';
WARNING: unpackaging raster
WARNING: PostGIS Raster functionality has been unpackaged
Expand All @@ -134,12 +134,12 @@ Step 2 - Upgrade to PostGIS version 3.1.2

With PostGIS version 3.1.2, the return type of the raster functions has changed, which requires dropping and creating the raster extension as part of the upgrade process.

```text
```sql
edb=# drop extension postgis_raster;
DROP EXTENSION
```

```text
```sql
edb=# SELECT postgis_extensions_upgrade();
NOTICE: Updating extension postgis_sfcgal from 3.1.1 to 3.1.2
NOTICE: Updating extension postgis_topology from 3.1.1 to 3.1.2
Expand All @@ -150,19 +150,19 @@ Step 2 - Upgrade to PostGIS version 3.1.2
(1 row)
```

```text
```sql
edb=# alter extension address_standardizer update to '3.1.2';
ALTER EXTENSION
```

Quit and re-open the psql client session:

```text
```sql
edb=# \q
./psql -d edb -p 5444
```

```text
```sql
edb=# create extension postgis_raster;
CREATE EXTENSION
```
Expand All @@ -171,39 +171,39 @@ Step 3 - Upgrade EDB Postgres Advanced Server version 9.6 to to 13:

1. Assume the superuser privileges to stop the EDB Postgres Advanced Server 9.6 service:

```text
```shell
systemctl stop edb-as-9.6
```

2. Install the EDB Postgres Advanced Server version 13:

```text
```shell
yum install edb-as13-server -y
```

3. Navigate to the bin directory of EDB Advanced Server 13 and initialize the cluster:

```text
```shell
cd /usr/edb/as13/bin/

./edb-as-13-setup initdb
```

4. Install the PostGIS version 3.1.2 for EDB Postgres Advanced Server version 13.0:

```text
```shell
yum install edb-as13-postgis3-3.1.2 -y
```

5. Assume the superuser privileges to stop the EDB Postgres Advanced Server 13.0 service:

```text
```shell
systemctl stop edb-as-13
```

6. Switch to `enterprisedb` user and create a `temp` folder:

```text
```shell
su enterprisedb
cd $(mktemp -d)
```
Expand Down Expand Up @@ -300,15 +300,15 @@ Step 3 - Upgrade EDB Postgres Advanced Server version 9.6 to to 13:

8. Assume the superuser privileges, navigate to the `bin` directory of EDB Postgres Advanced Server 13, and start the service:

```text
```shell
cd /usr/edb/as13/bin/

systemctl start edb-as-13
```

9. To update extensions, switch to `enterprisedb` user, connect to the database (where you have already created extensions) with the psql client application, and execute the following commands:

```text
```sql
su enterprisedb
./psql -d edb -p 5444
edb=# SELECT PostGIS_Extensions_Upgrade();
Expand Down
21 changes: 10 additions & 11 deletions product_docs/docs/postgis/3.1/04_using_postgis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ The following examples use PostGIS functions to create and query spatial objects

The following command creates a table named `roads` that holds GIS data and a geometry column.

```text
```sql
CREATE TABLE roads ( ID int4, NAME varchar(128) );
```

Use the PostGIS `AddGeometryColumn` function to add a column to the table:

```text
```sql
SELECT AddGeometryColumn( 'roads', 'geom', -1, 'GEOMETRY', 2 );
```

Use the following SQL commands to insert data into the table `roads`. This data consists of the geometry of the type of `Linestring` (a line between two points):

```text
```sql
INSERT INTO ROADS (ID,GEOM,NAME ) VALUES (1,ST_GeomFromText('LINESTRING(0 10,0 0)',-1),'Beacon Road');
INSERT INTO ROADS (ID,GEOM,NAME ) VALUES (2,ST_GeomFromText('LINESTRING(0 0,0 10)',-1),'Violet Road');
INSERT INTO ROADS (ID,GEOM,NAME ) VALUES (3,ST_GeomFromText('LINESTRING(0 0,10 0)',-1),'Skelton Street');
Expand All @@ -35,15 +35,15 @@ INSERT INTO ROADS (ID,GEOM,NAME ) VALUES (6,ST_GeomFromText('LINESTRING(10 0,0 0

You can use the `GIST` function to create an index on the geometry column:

```text
```sql
CREATE INDEX roads_index ON roads using GIST (geom);
```

`AsText(geometry)` is a PostGIS function that returns a text representation of the geometry:

```text
```sql
SELECT id, ST_AsText(geom) AS geom, name FROM ROADS order by id;
__OUTPUT__
id | geom | name
----+-----------------------+----------------
1 | LINESTRING(0 10,0 0) | Bacon Road
Expand All @@ -57,9 +57,9 @@ SELECT id, ST_AsText(geom) AS geom, name FROM ROADS order by id;

After an index is created, you can use the `&&` operator in a query:

```text
```sql
SELECT NAME, ST_AsText(GEOM) FROM ROADS WHERE GEOM && SetSRID('BOX3D(10 10,10 10)'::box3d,-1);
__OUTPUT__
name | astext
--------------+-----------------------
Fifth Avenue | LINESTRING(0 0,10 10)
Expand All @@ -70,10 +70,9 @@ Use the `BOX3D` function to specify a bounding box. The `&&` operator uses the i

You can use the `~=` operator to check if two geometries are geometrically identical:

```text
```sql
SELECT ID, NAME FROM roads WHERE GEOM ~= ST_GeomFromText('LINESTRING(0 10,0 0)',-1) order by id;
__OUTPUT__
id | name
----+-------------
1 | Bacon Road
Expand Down
12 changes: 6 additions & 6 deletions product_docs/docs/postgis/3.1/05_uninstalling_postgis.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@ To uninstall PostGIS on a CentOS/RHEL host, assume the identity of the root user

On CentOS/RHEL 7 for EPAS version 13:

```text
```shell
yum -y erase edb-as13-postgis3*
```

On CentOS/RHEL 7 for older versions of EPAS:

```text
```shell
yum erase edb-as<xx>-postgis-*<y.y.y>
```

Where *&lt;xx>* is the Advanced Server version and &lt;y.y.y> is the PostGIS version you want to uninstall.

On Rocky Linux/AlmaLinux/RHEL 8 for EPAS version 13:

```text
```shell
dnf -y erase edb-as13-postgis3*
```

On Rocky Linux/AlmaLinux/RHEL 8 for older versions of EPAS:

```text
```shell
dnf erase edb-as<xx>-postgis-*<y.y.y>
```

## Uninstalling PostGIS on a Debian/Ubuntu host

To uninstall PostGIS on a Debian or Ubuntu host, invoke the following command:

```text
```shell
apt-get remove edb-as<xx>-postgis-<y.y>*
```

Expand All @@ -54,7 +54,7 @@ Where *&lt;xx>* is the Advanced Server version and &lt;y.y> is the PostGIS versi

To uninstall PostGIS on a SLES host, assume the identity of the root user and invoke the following command:

```text
```shell
zypper remove edb-as12-postgis*
```

Expand Down

0 comments on commit 5e8382c

Please sign in to comment.