100% found this document useful (1 vote)
38 views

Procedural Programming with PostgreSQL PL/pgSQL: Design Complex Database-Centric Applications with PL/pgSQL 1st Edition Baji Shaik pdf download

The document is a promotional overview of the book 'Procedural Programming with PostgreSQL PL/pgSQL' by Baji Shaik and Dinesh Kumar Chemuduru, which focuses on designing complex database-centric applications using PL/pgSQL. It includes links to download the book and other related titles, as well as a detailed table of contents outlining various chapters covering PL/pgSQL concepts, variables, data types, control statements, and more. The book aims to provide comprehensive guidance for developers working with PostgreSQL.

Uploaded by

lobanisamaul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
38 views

Procedural Programming with PostgreSQL PL/pgSQL: Design Complex Database-Centric Applications with PL/pgSQL 1st Edition Baji Shaik pdf download

The document is a promotional overview of the book 'Procedural Programming with PostgreSQL PL/pgSQL' by Baji Shaik and Dinesh Kumar Chemuduru, which focuses on designing complex database-centric applications using PL/pgSQL. It includes links to download the book and other related titles, as well as a detailed table of contents outlining various chapters covering PL/pgSQL concepts, variables, data types, control statements, and more. The book aims to provide comprehensive guidance for developers working with PostgreSQL.

Uploaded by

lobanisamaul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Procedural Programming with PostgreSQL PL/pgSQL:

Design Complex Database-Centric Applications


with PL/pgSQL 1st Edition Baji Shaik pdf
download
https://ebookmeta.com/product/procedural-programming-with-
postgresql-pl-pgsql-design-complex-database-centric-applications-
with-pl-pgsql-1st-edition-baji-shaik/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

PostgreSQL Configuration: Best Practices for


Performance and Security 1st Edition Baji Shaik

https://ebookmeta.com/product/postgresql-configuration-best-
practices-for-performance-and-security-1st-edition-baji-shaik-2/

PostgreSQL Configuration: Best Practices for


Performance and Security 1st Edition Baji Shaik

https://ebookmeta.com/product/postgresql-configuration-best-
practices-for-performance-and-security-1st-edition-baji-shaik/

Resilient Oracle PL/SQL: Building Resilient Database


Solutions for Continuous Operation 1st Edition Stephen
Morris

https://ebookmeta.com/product/resilient-oracle-pl-sql-building-
resilient-database-solutions-for-continuous-operation-1st-
edition-stephen-morris/

Home to Roost Bower Colorado 1st Edition Reina Torres


Torres Reina

https://ebookmeta.com/product/home-to-roost-bower-colorado-1st-
edition-reina-torres-torres-reina/
Pull Up a Chair Recipes from My Family to Yours Rachel
Holtzman

https://ebookmeta.com/product/pull-up-a-chair-recipes-from-my-
family-to-yours-rachel-holtzman/

Moving Ideas Multimodality and Embodied Learning in


Communities and Schools New Literacies and Digital
Epistemologies Mira-Lisa Katz (Editor)

https://ebookmeta.com/product/moving-ideas-multimodality-and-
embodied-learning-in-communities-and-schools-new-literacies-and-
digital-epistemologies-mira-lisa-katz-editor/

St Dominic The Story of a Preaching Friar Donald J


Goergen

https://ebookmeta.com/product/st-dominic-the-story-of-a-
preaching-friar-donald-j-goergen/

Bred by the Mafia Monster Breeding Season 7 1st Edition


Sam Crescent Stacey Espino

https://ebookmeta.com/product/bred-by-the-mafia-monster-breeding-
season-7-1st-edition-sam-crescent-stacey-espino/

The Other Alcott 1st Edition Elise Hooper

https://ebookmeta.com/product/the-other-alcott-1st-edition-elise-
hooper/
Routledge Handbook of Identity Studies 2nd Edition
Anthony Elliott

https://ebookmeta.com/product/routledge-handbook-of-identity-
studies-2nd-edition-anthony-elliott/
Q L
S
E
AG
NGU
Y LA
ER
D QU
RE
TU
RUC
ST

B
TA

Procedural Programming DA

with PostgreSQL DA
TAB
A SE

DA
T

PL/pgSQL
Design Complex Database-Centric
Applications with PL/pgSQL

Baji Shaik
Dinesh Kumar Chemuduru
Procedural Programming
with PostgreSQL
PL/pgSQL
Design Complex Database-Centric
Applications with PL/pgSQL

Baji Shaik
Dinesh Kumar Chemuduru
Procedural Programming with PostgreSQL PL/pgSQL: Design Complex
Database-­Centric Applications with PL/pgSQL
Baji Shaik Dinesh Kumar Chemuduru
Texas, TX, USA Andhra Pradesh, India

ISBN-13 (pbk): 978-1-4842-9839-8 ISBN-13 (electronic): 978-1-4842-9840-4


https://doi.org/10.1007/978-1-4842-9840-4

Copyright © 2023 by Baji Shaik and Dinesh Kumar Chemuduru


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Divya Modi
Development Editor: James Markham
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004,
U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit
www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer
Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available
to readers on GitHub (https://github.com/Apress). For more detailed information, please visit
https://www.apress.com/gp/services/source-code.
Paper in this product is recyclable
I extend this dedication to Afrah Razzak, my exceptional wife.
Her enduring support and remarkable patience during the extended
writing sessions have been invaluable to me.
—Baji Shaik

I lovingly extend this dedication to my dear friend, Baji Shaik.


Your unwavering support and encouragement have been my guiding
light, especially in the most challenging moments. Your belief in me has
been a constant source of inspiration, and I am grateful for your
presence in my journey. This book is as much a tribute to our
friendship as it is a testament to the power of steadfast camaraderie.
Thank you for always being there.
—Dinesh Kumar Chemuduru
Table of Contents
About the Authors�������������������������������������������������������������������������������������������������� xiii

About the Technical Reviewer���������������������������������������������������������������������������������xv

Acknowledgments�������������������������������������������������������������������������������������������������xvii
Introduction������������������������������������������������������������������������������������������������������������xix

Chapter 1: Introduction to PL/pgSQL������������������������������������������������������������������������ 1


A Closer Look at PL/pgSQL����������������������������������������������������������������������������������������������������������� 1
PL/pgSQL Installation�������������������������������������������������������������������������������������������������������������������� 2
PL/pgSQL Execution Flow������������������������������������������������������������������������������������������������������������� 4
PL/pgSQL Blocks��������������������������������������������������������������������������������������������������������������������������� 6
Anonymous or Unnamed Blocks���������������������������������������������������������������������������������������������� 6
Named Blocks����������������������������������������������������������������������������������������������������������������������������� 10
Summary������������������������������������������������������������������������������������������������������������������������������������ 12
What’s Next��������������������������������������������������������������������������������������������������������������������������������� 12

Chapter 2: PL/pgSQL Variables������������������������������������������������������������������������������� 13


What Are Variables in PL/pgSQL?������������������������������������������������������������������������������������������������ 13
Declaring Variables��������������������������������������������������������������������������������������������������������������������� 13
Variable Scope���������������������������������������������������������������������������������������������������������������������������� 15
Constant Variables���������������������������������������������������������������������������������������������������������������������� 17
Variable Alias������������������������������������������������������������������������������������������������������������������������������ 18
Scalar Variables��������������������������������������������������������������������������������������������������������������������� 19
Array Variables���������������������������������������������������������������������������������������������������������������������� 21
Record Variables�������������������������������������������������������������������������������������������������������������������� 22
Cursor Variables�������������������������������������������������������������������������������������������������������������������� 23

v
Table of Contents

Summary������������������������������������������������������������������������������������������������������������������������������������ 25
What’s Next��������������������������������������������������������������������������������������������������������������������������������� 25

Chapter 3: PL/pgSQL Data Types���������������������������������������������������������������������������� 27


Data Types����������������������������������������������������������������������������������������������������������������������������������� 27
Declaring Variables with Data Types������������������������������������������������������������������������������������������� 28
Supported Types������������������������������������������������������������������������������������������������������������������������� 30
Base Type������������������������������������������������������������������������������������������������������������������������������������ 32
Composite Type��������������������������������������������������������������������������������������������������������������������������� 33
Domain Type�������������������������������������������������������������������������������������������������������������������������������� 35
Pseudo-Type������������������������������������������������������������������������������������������������������������������������������� 37
Range Type���������������������������������������������������������������������������������������������������������������������������������� 38
Multirange Types������������������������������������������������������������������������������������������������������������������������� 40
Summary������������������������������������������������������������������������������������������������������������������������������������ 41
What’s Next��������������������������������������������������������������������������������������������������������������������������������� 41

Chapter 4: Dealing with Strings, Numbers, and Arrays������������������������������������������ 43


Strings����������������������������������������������������������������������������������������������������������������������������������������� 43
Function Format�������������������������������������������������������������������������������������������������������������������� 45
Dealing with Null String��������������������������������������������������������������������������������������������������������� 47
Numbers������������������������������������������������������������������������������������������������������������������������������������� 50
Arrays������������������������������������������������������������������������������������������������������������������������������������������ 53
Example Use Cases��������������������������������������������������������������������������������������������������������������������� 54
Strings����������������������������������������������������������������������������������������������������������������������������������������� 54
Numbers�������������������������������������������������������������������������������������������������������������������������������� 55
Arrays������������������������������������������������������������������������������������������������������������������������������������ 57
Summary������������������������������������������������������������������������������������������������������������������������������������ 58
What’s Next��������������������������������������������������������������������������������������������������������������������������������� 59

Chapter 5: Control Statements������������������������������������������������������������������������������� 61


IF/ELSE Statement���������������������������������������������������������������������������������������������������������������������� 62
Cascading IF Statements������������������������������������������������������������������������������������������������������� 65
CASE Statement�������������������������������������������������������������������������������������������������������������������������� 66
vi
Table of Contents

Iterative Statement��������������������������������������������������������������������������������������������������������������������� 68
LOOP Statement�������������������������������������������������������������������������������������������������������������������� 69
WHILE Statement������������������������������������������������������������������������������������������������������������������������ 72
FOR Statement���������������������������������������������������������������������������������������������������������������������������� 74
Example Use Cases��������������������������������������������������������������������������������������������������������������������� 78
Example 1������������������������������������������������������������������������������������������������������������������������������ 78
Example 2������������������������������������������������������������������������������������������������������������������������������ 81
Best Practices of Using Control Statements in PL/pgSQL����������������������������������������������������� 84
Summary������������������������������������������������������������������������������������������������������������������������������������ 85
What’s Next��������������������������������������������������������������������������������������������������������������������������������� 85

Chapter 6: Handling Arrays������������������������������������������������������������������������������������ 87


Array Index���������������������������������������������������������������������������������������������������������������������������������� 88
Array Length������������������������������������������������������������������������������������������������������������������������������� 89
Iterate Array�������������������������������������������������������������������������������������������������������������������������������� 91
Find Duplicate Elements in Array������������������������������������������������������������������������������������������������ 92
Append Elements to Array����������������������������������������������������������������������������������������������������������� 93
Array Merge�������������������������������������������������������������������������������������������������������������������������������� 94
Multidimensional Arrays������������������������������������������������������������������������������������������������������������� 94
Summary������������������������������������������������������������������������������������������������������������������������������������ 96
What’s Next��������������������������������������������������������������������������������������������������������������������������������� 96

Chapter 7: Handling JSON�������������������������������������������������������������������������������������� 97


What Is JSON?���������������������������������������������������������������������������������������������������������������������������� 97
Use Cases��������������������������������������������������������������������������������������������������������������������������������� 100
Advantages and Disadvantages������������������������������������������������������������������������������������������������ 104
Build PL/pgSQL Functions for JSON������������������������������������������������������������������������������������������ 105
Indexing JSON Data������������������������������������������������������������������������������������������������������������������ 109
Other Useful JSON Functions���������������������������������������������������������������������������������������������������� 111
Summary���������������������������������������������������������������������������������������������������������������������������������� 111
What’s Next������������������������������������������������������������������������������������������������������������������������������� 112

vii
Table of Contents

Chapter 8: Cursors������������������������������������������������������������������������������������������������ 113


What Are Cursors?�������������������������������������������������������������������������������������������������������������������� 113
CURSOR Attributes��������������������������������������������������������������������������������������������������������������� 115
ISOPEN Attribute������������������������������������������������������������������������������������������������������������������ 115
FOUND Attribute������������������������������������������������������������������������������������������������������������������� 117
NOTFOUND Attribute������������������������������������������������������������������������������������������������������������ 119
ROWCOUNT Attribute����������������������������������������������������������������������������������������������������������� 120
Monitor Cursors������������������������������������������������������������������������������������������������������������������� 122
SCROLL Cursor�������������������������������������������������������������������������������������������������������������������� 123
NO SCROLL Cursor��������������������������������������������������������������������������������������������������������������� 125
WITH HOLD Cursors������������������������������������������������������������������������������������������������������������� 127
Refcursors��������������������������������������������������������������������������������������������������������������������������� 128
Summary���������������������������������������������������������������������������������������������������������������������������������� 130
What’s Next������������������������������������������������������������������������������������������������������������������������������� 130

Chapter 9: Custom Operators������������������������������������������������������������������������������� 131


Built-In Operators���������������������������������������������������������������������������������������������������������������������� 131
Creating a Custom Operator������������������������������������������������������������������������������������������������������ 135
Simple Example������������������������������������������������������������������������������������������������������������������� 136
SCENARIO 1: Case-Insensitive Comparison������������������������������������������������������������������������� 140
SCENARIO 2: Custom Data Type Math��������������������������������������������������������������������������������� 142
SCENARIO 3: Date Differentiate Operator���������������������������������������������������������������������������� 144
SCENARIO 4: Custom Operator for Data Classification�������������������������������������������������������� 146
Advantages������������������������������������������������������������������������������������������������������������������������������� 148
Disadvantages�������������������������������������������������������������������������������������������������������������������������� 149
Summary���������������������������������������������������������������������������������������������������������������������������������� 149
What’s Next������������������������������������������������������������������������������������������������������������������������������� 149

Chapter 10: Custom Casting��������������������������������������������������������������������������������� 151


Built-In Casts���������������������������������������������������������������������������������������������������������������������������� 151
Custom Casts���������������������������������������������������������������������������������������������������������������������������� 160

viii
Table of Contents

Creating a Custom Cast������������������������������������������������������������������������������������������������������� 160


Simple Example������������������������������������������������������������������������������������������������������������������� 161
SCENARIO 1: Converting Custom Data Types����������������������������������������������������������������������� 163
SCENARIO 2: Custom Data Type to JSONB��������������������������������������������������������������������������� 165
Summary���������������������������������������������������������������������������������������������������������������������������������� 168
What’s Next������������������������������������������������������������������������������������������������������������������������������� 168

Chapter 11: Dynamic SQL������������������������������������������������������������������������������������� 169


What Is Dynamic SQL?�������������������������������������������������������������������������������������������������������������� 169
Syntax of Dynamic SQL in PL/pgSQL����������������������������������������������������������������������������������� 169
Simple Example������������������������������������������������������������������������������������������������������������������� 170
Use Cases of Dynamic SQL�������������������������������������������������������������������������������������������������� 171
Best Practices and Considerations for Dynamic SQL���������������������������������������������������������������� 178
1. Preventing SQL Injection������������������������������������������������������������������������������������������������� 179
2. Sanitizing and Validating Inputs�������������������������������������������������������������������������������������� 179
3. Security Concerns����������������������������������������������������������������������������������������������������������� 180
4. Performance Optimization����������������������������������������������������������������������������������������������� 180
Summary���������������������������������������������������������������������������������������������������������������������������������� 181
What’s Next������������������������������������������������������������������������������������������������������������������������������� 181

Chapter 12: Building Functions and Procedures�������������������������������������������������� 183


Functions���������������������������������������������������������������������������������������������������������������������������������� 183
Defining Functions��������������������������������������������������������������������������������������������������������������� 184
Calling Functions����������������������������������������������������������������������������������������������������������������� 184
Categories��������������������������������������������������������������������������������������������������������������������������������� 185
Immutable Functions���������������������������������������������������������������������������������������������������������������� 186
STABLE Functions��������������������������������������������������������������������������������������������������������������������� 188
VOLATILE Functions������������������������������������������������������������������������������������������������������������������� 191
Procedures�������������������������������������������������������������������������������������������������������������������������������� 194
Temporary Functions/Procedures��������������������������������������������������������������������������������������������� 195
VARIADIC Functions/Procedures����������������������������������������������������������������������������������������������� 196
Best Practices���������������������������������������������������������������������������������������������������������������������� 198

ix
Table of Contents

Summary���������������������������������������������������������������������������������������������������������������������������������� 199
What’s Next������������������������������������������������������������������������������������������������������������������������������� 199

Chapter 13: Return Values and Parameters���������������������������������������������������������� 201


Return Values���������������������������������������������������������������������������������������������������������������������������� 201
Simple Example������������������������������������������������������������������������������������������������������������������� 202
Different Ways to Return Values������������������������������������������������������������������������������������������������ 203
RETURNS����������������������������������������������������������������������������������������������������������������������������� 203
RETURNS SETOF������������������������������������������������������������������������������������������������������������������ 204
RETURNS TABLE������������������������������������������������������������������������������������������������������������������ 204
OUT�������������������������������������������������������������������������������������������������������������������������������������� 205
Simple Difference Matrix����������������������������������������������������������������������������������������������������� 206
Different Examples for Each RETURN Type�������������������������������������������������������������������������� 206
Using SELECT Statements��������������������������������������������������������������������������������������������������� 207
Using RETURNS TABLE�������������������������������������������������������������������������������������������������������� 208
Using RETURN NEXT������������������������������������������������������������������������������������������������������������ 209
Using RETURNS SETOF TABLE��������������������������������������������������������������������������������������������� 210
Using RETURNS SETOF Data Type���������������������������������������������������������������������������������������� 210
Using RETURNS RECORD����������������������������������������������������������������������������������������������������� 211
Using RETURNS SETOF RECORD������������������������������������������������������������������������������������������ 212
Using OUT Parameters��������������������������������������������������������������������������������������������������������� 214
Using INOUT Parameter������������������������������������������������������������������������������������������������������� 216
Summary���������������������������������������������������������������������������������������������������������������������������������� 216
What’s Next������������������������������������������������������������������������������������������������������������������������������� 217

Chapter 14: Handling Exceptions�������������������������������������������������������������������������� 219


Exceptions��������������������������������������������������������������������������������������������������������������������������������� 219
GET DIAGNOSTICS���������������������������������������������������������������������������������������������������������������� 219
FOUND��������������������������������������������������������������������������������������������������������������������������������� 223
Exceptions in PL/pgSQL������������������������������������������������������������������������������������������������������������ 225
Different Ways to Handle Exceptions in PL/pgSQL�������������������������������������������������������������� 226
Using the BEGIN and END Statements��������������������������������������������������������������������������������� 226

x
Table of Contents

Using the RAISE Statement������������������������������������������������������������������������������������������������� 231


Custom Exceptions�������������������������������������������������������������������������������������������������������������� 232
Rethrow Exceptions������������������������������������������������������������������������������������������������������������� 233
ASSERT�������������������������������������������������������������������������������������������������������������������������������� 234
Get Call Stack���������������������������������������������������������������������������������������������������������������������� 235
Using the GET STACKED DIAGNOSTICS Statement�������������������������������������������������������������� 237
Advantages of Using Exceptions����������������������������������������������������������������������������������������� 238
Disadvantages of Using Exceptions������������������������������������������������������������������������������������� 239
Summary���������������������������������������������������������������������������������������������������������������������������������� 239
What’s Next������������������������������������������������������������������������������������������������������������������������������� 240

Chapter 15: Triggers��������������������������������������������������������������������������������������������� 241


What Are Triggers?�������������������������������������������������������������������������������������������������������������������� 241
Syntax���������������������������������������������������������������������������������������������������������������������������������� 242
Simple Example������������������������������������������������������������������������������������������������������������������� 243
Types of Triggers in PostgreSQL������������������������������������������������������������������������������������������������ 245
Row-Level Triggers�������������������������������������������������������������������������������������������������������������� 246
INSTEAD OF Triggers������������������������������������������������������������������������������������������������������������ 253
Statement-Level Triggers���������������������������������������������������������������������������������������������������� 254
Event Triggers���������������������������������������������������������������������������������������������������������������������� 258
Advantages of Triggers�������������������������������������������������������������������������������������������������������� 260
Disadvantages of Triggers��������������������������������������������������������������������������������������������������� 261
DROP Triggers��������������������������������������������������������������������������������������������������������������������������� 261
Summary���������������������������������������������������������������������������������������������������������������������������������� 262
What’s Next������������������������������������������������������������������������������������������������������������������������������� 262

Chapter 16: Transaction Management������������������������������������������������������������������ 263


Nested Transactions������������������������������������������������������������������������������������������������������������������ 263
Exception Handling������������������������������������������������������������������������������������������������������������������� 266
Summary���������������������������������������������������������������������������������������������������������������������������������� 270
What’s Next������������������������������������������������������������������������������������������������������������������������������� 270

xi
Table of Contents

Chapter 17: Aggregates���������������������������������������������������������������������������������������� 271


Custom Aggregate��������������������������������������������������������������������������������������������������������������������� 271
Simple Example������������������������������������������������������������������������������������������������������������������� 272
State Transition Function����������������������������������������������������������������������������������������������������� 273
Final Function���������������������������������������������������������������������������������������������������������������������� 275
Creating Custom Aggregate������������������������������������������������������������������������������������������������� 276
Create Type�������������������������������������������������������������������������������������������������������������������������� 277
Create State Transition Function����������������������������������������������������������������������������������������� 277
Create Aggregate����������������������������������������������������������������������������������������������������������������� 278
Final Function���������������������������������������������������������������������������������������������������������������������� 279
Summary���������������������������������������������������������������������������������������������������������������������������������� 281
What’s Next������������������������������������������������������������������������������������������������������������������������������� 281

Chapter 18: Listen and Notify������������������������������������������������������������������������������� 283


Simple Example������������������������������������������������������������������������������������������������������������������������ 283
Build Polling in psql������������������������������������������������������������������������������������������������������������������ 285
TCN Extension��������������������������������������������������������������������������������������������������������������������������� 290
Summary���������������������������������������������������������������������������������������������������������������������������������� 292
What’s Next������������������������������������������������������������������������������������������������������������������������������� 292

Chapter 19: PL/pgSQL Essential Extensions��������������������������������������������������������� 293


plprofiler Extension������������������������������������������������������������������������������������������������������������������� 293
Installation��������������������������������������������������������������������������������������������������������������������������� 295
Usage����������������������������������������������������������������������������������������������������������������������������������� 296
plpgsql_check Extension���������������������������������������������������������������������������������������������������������� 305
Installation��������������������������������������������������������������������������������������������������������������������������� 305
Usage����������������������������������������������������������������������������������������������������������������������������������� 306
Summary���������������������������������������������������������������������������������������������������������������������������������� 309

Index��������������������������������������������������������������������������������������������������������������������� 311

xii
About the Authors
Baji Shaik, currently serving as a Senior Database
Consultant at AWS Professional Services, embarked on
his journey into the world of databases in 2011. Since
then, his expertise has encompassed an array of database
technologies, including Oracle, PostgreSQL, EDB Postgres,
Amazon RDS, Amazon Aurora, Amazon Redshift, and
Greenplum. Baji’s extensive background spans both depth
and breadth, showcasing his mastery in SQL/NoSQL
database technologies.
Baji stands out as a Database Migration Expert, having
successfully developed numerous database solutions that
tackle complex business challenges, particularly in migrating databases from on-
premises environments to Amazon RDS and Aurora PostgreSQL/MySQL. His prowess
also extends to performance optimization, having fine-tuned RDS/Aurora PostgreSQL/
MySQL databases to achieve remarkable performance benchmarks.
With a passion for knowledge sharing, Baji has authored several notable books on
PostgreSQL, such as PostgreSQL Configuration, Beginning PostgreSQL on the Cloud, and
PostgreSQL Development Essentials. His commitment to education and information
dissemination is further evident through his contributions to conferences, workshops,
and a multitude of insightful blogs within the AWS blog community.

Dinesh Kumar Chemuduru, an accomplished Principal


Architect (OSS), brings a wealth of experience to the realm
of technology and open source solutions. With a notable
background at AWS as a proficient database consultant,
Dinesh excelled in orchestrating numerous successful
database migrations. His expertise extends to the open
source arena, where he has both crafted and augmented
solutions around PostgreSQL, showcasing his commitment
to collaborative innovation.

xiii
About the Authors

A coding enthusiast at heart, Dinesh finds joy in crafting applications using Flutter,
Golang, and C++, platforms where his creativity knows no bounds. His proficiency
extends to the deployment phase, as he deftly navigates Kubernetes to bring his coding
creations to life. In the literary domain, Dinesh stands as a coauthor of the esteemed
PostgreSQL High Performance Cookbook, a testament to his mastery of the subject
matter. Beyond his own works, he actively engages in the appraisal of fellow authors’
PostgreSQL books, cementing his status as a valued participant in the exchange of
knowledge.
Dinesh’s impact reverberates through his open source contributions, which include
the inception and enrichment of projects such as PTOR – an ingenious RPO/RTO/SLA
calculator tailored for PostgreSQL. Another tool, “hammerpost,” sets a benchmark for
synthetic parameter evaluation in PostgreSQL, seamlessly integrated with HammerDB.

xiv
About the Technical Reviewer
Deepak Ramnandan Mahto works as a PostgreSQL
Database Engineer at Google Cloud. He has been working
with PostgreSQL since 2018, and he also worked as a
database migration consultant at AWS. He is also a keen
blogger and loves to publish articles on migration, best
practices, and on cloud with PostgreSQL. He loves to
code and build database-related utilities using PL/pgSQL
and SQL.

xv
Exploring the Variety of Random
Documents with Different Content
themselves, are the more precious from the
circumstance that at the present day he is the only
author extant who relates them. It is to be regretted
however that the manner in which he has collected
and grouped this mass of matter, has caused it to
lose some portion of its value, from his mixture of
fable with truth, and more especially from the
difficulty, and in some cases, the impossibility, of
discovering exactly of what object33 he is speaking.
But if Pliny possesses little merit as a critic, it is far
otherwise with his talent as a writer, and the
immense treasury which he opens to us of Latin
terms and forms of expression: these, from the very
abundance of the subjects upon which he treats,
render his work one of the richest repositories of the
Roman language. Wherever he finds it possible to
give expression to general ideas or to philosophical
views, his language assumes considerable energy
and vivacity, and his thoughts present to us a certain
novelty and boldness which tend in a very great
degree to relieve the dryness of his enumerations,
and, with the majority of his readers, excuse the
insufficiency of his scientific indications. He is always
noble and serious, full of the love of justice and
virtue, detestation of cruelty and baseness, of which
he had such frightful instances before his eyes, and
contempt for that unbridled luxury which in his time
had so deeply corrupted the Roman people. For
these great merits Pliny cannot be too highly praised,
and despite the faults which we are obliged to admit
in him when viewed as a naturalist, we are bound to
regard him as one of the most meritorious of the
Roman writers, and among those most worthy to be
reckoned in the number of the classics who wrote
after the reign of Augustus.”
CONTENTS.

OF THE FIRST VOLUME.

BOOK I.

DEDICATION.
Page
C. Plinius Secundus to his friend Titus
Vespasian 1

BOOK II.

AN ACCOUNT OF THE WORLD AND THE ELEMENTS.


Chap.
1. Whether the world be finite, and
whether there be more than one
world 13
2. Of the form of the world 16
3. Of its nature; whence the name is
derived ib.
4. Of the elements and the planets 18
5. Of God 20
6. Of the nature of the stars; of the 25
motion of the planets
7. Of the eclipses of the moon and the
sun 34
8. Of the magnitude of the stars 35
9. An account of the observations that
have been made on the heavens by
different individuals 36
10. On the recurrence of the eclipses of
the sun and the moon 38
11. Of the motion of the moon 40
12. Of the motions of the planets and the
general laws of their aspects ib.
13. Why the same stars appear at some
times more lofty and at other times
more near 42
14. Why the same stars have different
motions 47
15. General laws of the planets 48
16. The reason why the stars are of
different colours 49
17. Of the motion of the sun and the
cause of the irregularity of the days 50
18. Why thunder is ascribed to Jupiter 51
19. Of the distances of the stars 52
20. Of the harmony of the stars ib.
21. Of the dimensions of the world 53
22. Of the stars which appear suddenly, or
of comets 55
23. Their nature, situation, and species 56
24. The doctrine of Hipparchus about the
stars 59
25. Examples from history of celestial
prodigies; Faces, Lampades, and
Bolides ib.
26. Trabes Cælestes; Chasma Cæli 60
27. Of the colours of the sky and of
celestial flame ib.
28. Of celestial coronæ 61
29. Of sudden circles 62
30. Of unusually long eclipses of the sun ib.
31. Many suns ib.
32. Many moons 63
33. Daylight in the night ib.
34. Burning shields ib.
35. An ominous appearance in the
heavens, that was seen once only ib.
36. Of stars which move about in various
directions 64
37. Of the stars which are named Castor
and Pollux ib.
38. Of the air, and on the cause of the
showers of stones 65
39. Of the stated seasons 66
40. Of the rising of the dog-star 67
41. Of the regular influence of the
different seasons ib.
42. Of uncertain states of the weather 69
43. Of thunder and lightning ib.
44. The origin of winds 70
45. Various observations respecting winds 71
46. The different kinds of winds 73
47. The periods of the winds 75
48. Nature of the winds 77
49. Ecnephias and Typhon 79
50. Tornadoes; blasting winds; whirlwinds,
and other wonderful kinds of
tempests 80
51. Of thunder; in what countries it does
not fall, and for what reason ib.
52. Of the different kinds of lightning and
their wonderful effects 81
53. The Etrurian and the Roman
observations on these points 82
54. Of conjuring up thunder 83
55. General laws of lightning 84
56. Objects which are never struck 86
57. Showers of milk, blood, flesh, iron,
wool, and baked tiles 87
58. Rattling of arms and the sound of
trumpets heard in the sky 88
59. Of stones that have fallen from the
clouds. The opinion of Anaxagoras
respecting them ib.
60. The rainbow 89
61. The nature of hail, snow, hoar, mist,
dew; the forms of clouds 90
62. The peculiarities of the weather in
different places 91
63. Nature of the earth ib.
64. Of the form of the earth 94
65. Whether there be antipodes? ib.
66. How the water is connected with the
earth. Of the navigation of the sea
and the rivers 97
67. Whether the ocean surrounds the
earth 98
68. What part of the earth is inhabited 100
69. That the earth is in the middle of the
world 102
70. Of the obliquity of the zones ib.
71. Of the inequality of climates ib.
72. In what places eclipses are invisible,
and why this is the case 104
73. What regulates the daylight on the
earth 105
74. Remarks on dials, as connected with
this subject 106
75. When and where there are no
shadows 107
76. Where this takes place twice in the
year and where the shadows fall in
opposite directions 108
77. Where the days are the longest and
where the shortest ib.
78. Of the first dial 109
79. Of the mode in which the days are
computed 110
80. Of the difference of nations as
depending on the nature of the
world ib.
81. Of earthquakes 111
82. Of clefts of the earth 112
83. Signs of an approaching earthquake 114
84. Preservatives against future
earthquakes ib.
85. Prodigies of the earth which have
occurred once only 115
86. Wonderful circumstances attending
earthquakes 116
87. In what places the sea has receded ib.
88. The mode in which islands rise up 117
89. What islands have been formed, and
at what periods 118
90. Lands which have been separated by
the sea 119
91. Islands which have been united to the
main land ib.
92. Lands which have been totally
changed into seas ib.
93. Lands which have been swallowed up 120
94. Cities which have been absorbed by
the sea ib.
95. Of vents in the earth 121
96. Of certain lands which are always
shaking, and of floating islands 122
97. Places in which it never rains 123
98. The wonders of various countries
collected together ib.
99. Concerning the cause of the flowing
and ebbing of the sea 124
100. Where the tides rise and fall in an
unusual manner 127
101. Wonders of the sea 128
102. The power of the moon over the land
and the sea ib.
103. The power of the sun 129
104. Why the sea is salt ib.
105. Where the sea is the deepest 130
106. The wonders of fountains and rivers 131
107. The wonders of fire and water united 138
108. Of Maltha 138
109. Of naphtha 139
110. Places which are always burning ib.
111. Wonders of fire alone 141
112. The dimensions of the earth 143
113. The harmonical proportion of the
universe 147

BOOK III.

AN ACCOUNT OF COUNTRIES, NATIONS, SEAS,


TOWNS, HAVENS, MOUNTAINS, RIVERS,
DISTANCES, AND PEOPLES WHO NOW EXIST OR
FORMERLY EXISTED.
Introduction 151
1. The boundaries and gulfs of Europe
first set forth in a general way 153
2. Of Spain generally ib.
3. Of Bætica 154
4. Of Nearer Spain 164
5. Of the province of Gallia Narbonensis 174
6. Of Italy 180
7. Of the ninth region of Italy 184
8. The seventh region of Italy 186
9. The first region of Italy; the Tiber;
Rome 191
10. The third region of Italy 207
11. Sixty-four islands, among which are
the Baleares 210
12. Corsica 213
13. Sardinia 215
14. Sicily 216
15. Magna Græcia, beginning at Locri 222
16. The second region of Italy 225
17. The fourth region of Italy 231
18. The fifth region of Italy 235
19. The sixth region of Italy 237
20. The eighth region of Italy; the Padus 241
21. The eleventh region of Italy; Italia
Transpadana 246
22. The tenth region of Italy 248
23. Istria, its people and locality 251
24. The Alps, and the Alpine nations 254
25. Liburnia and Illyricum 257
26. Dalmatia 259
27. The Norici 262
28. Pannonia 263
29. Mœsia 264
30. Islands of the Ionian Sea and the
Adriatic 265

BOOK IV.

AN ACCOUNT OF COUNTRIES, NATIONS, SEAS,


TOWNS, HAVENS, MOUNTAINS, RIVERS,
DISTANCES, AND PEOPLES WHO NOW EXIST OR
FORMERLY EXISTED.
1. Epirus 271
2. Acarnania 273
3. Ætolia 275
4. Locris and Phocis 276
5. The Peloponnesus 278
6. Achaia 280
7. Messenia 282
8. Laconia 283
9. Argolis 284
10. Arcadia 285
11. Attica 288
12. Bœotia 290
13. Doris 293
14. Phthiotis 293
15. Thessaly Proper 294
16. Magnesia 296
17. Macedonia 297
18. Thrace; the Ægean Sea 302
19. The islands which lie before the lands
already mentioned 310
20. Crete 313
21. Eubœa 316
22. The Cyclades 317
23. The Sporades 320
24. The Hellespont.—The lake Mæotis 326
25. Dacia, Sarmatia 329
26. Scythia 330
27. The islands of the Euxine. The islands
of the northern ocean 338
28. Germany 345
29. Ninety-six islands of the Gallic ocean 349
30. Britannia 350
31. Gallia Belgica 353
32. Gallia Lugdunensis 355
33. Gallia Aquitanica 357
34. Nearer Spain, its coast along the Gallic
ocean 360
35. Lusitania 363
36. The islands in the Atlantic ocean 367
37. The general measurement of Europe 369
BOOK V.

AN ACCOUNT OF COUNTRIES, NATIONS, SEAS,


TOWNS, HAVENS, MOUNTAINS, RIVERS,
DISTANCES, AND PEOPLES WHO NOW EXIST OR
FORMERLY EXISTED.
1. The two Mauritanias 374
2. Numidia 387
3. Africa 388
4. The Syrtes 391
5. Cyrenaica 395
6. Libya Mareotis 401
7. The islands in the vicinity of Africa 402
8. Countries on the other side of Africa 403
9. Egypt and Thebais 406
10. The River Nile 410
11. The cities of Egypt 416
12. The coasts of Arabia, situate on the
Egyptian Sea 422
13. Syria 423
14. Idumæa, Palæstina, and Samaria 424
15. Judæa 427
16. Decapolis 431
17. Phœnice 433
18. Syria Antiochia 436
19. The remaining parts of Syria 438
20. The Euphrates 441
21. Syria upon the Euphrates 443
22. Cilicia and the adjoining nations 446
23. Isauria and the Homonades 450
24. Pisidia 451
25. Lycaonia ib.
26. Pamphylia 452
27. Mount Taurus 453
28. Lycia 455
29. Caria 458
30. Lydia 465
31. Ionia 466
32. Æolis 472
33. Troas and the adjoining nations 476
34. The islands which lie in front of Asia 479
35. Cyprus 480
36. Rhodes 483
37. Samos 485
38. Chios 486
39. Lesbos 487
40. The Hellespont and Mysia 488
41. Phrygia 490
42. Galatia and the adjoining nations 491
43. Bithynia 493
44. The islands of the Propontis 496
NATURAL HISTORY OF PLINY
BOOK I.34

DEDICATION.

C. PLINIUS SECUNDUS TO HIS FRIEND TITUS VESPASIAN.

This treatise on Natural History, a novel work in


Roman literature, which I have just completed, I
have taken the liberty to dedicate to you, most
gracious35 Emperor, an appellation peculiarly suitable
to you, while, on account of his age, that of great is
more appropriate to your Father;—

“For still thou ne’er wouldst quite despise


The trifles that I write36;”

if I may be allowed to shelter myself under the


example of Catullus, my fellow-countryman37, a
military term, which you well understand. For he, as
you know, when his napkins had been changed38,
expressed himself a little harshly, from his anxiety to
show his friendship for his dear little Veranius and
Fabius39. At the same time this my importunity may
effect, what you complained of my not having done
in another too forward epistle of mine; it will put
upon record, and let all the world know, with what
kindness you exercise the imperial dignity. You, who
have had the honour of a triumph, and of the
censorship, have been six times consul, and have
shared in the tribunate; and, what is still more
honourable, whilst you held them in conjunction with
your Father, you have presided over the Equestrian
order, and been the Prefect of the Prætorians40: all
this you have done for the service of the Republic,
and, at the same time, have regarded me as a
fellow-soldier and a messmate. Nor has the extent of
your prosperity produced any change in you, except
that it has given you the power of doing good to the
utmost of your wishes. And whilst all these
circumstances increase the veneration which other
persons feel for you, with respect to myself, they
have made me so bold, as to wish to become more
familiar. You must, therefore, place this to your own
account, and blame yourself for any fault of this kind
that I may commit.
But, although I have laid aside my blushes41, I
have not gained my object; for you still awe me, and
keep me at a distance, by the majesty of your
understanding. In no one does the force of
eloquence and of tribunitian oratory blaze out more
powerfully! With what glowing language do you
thunder forth the praises of your Father! How dearly
do you love your Brother! How admirable is your
talent for poetry! What a fertility of genius do you
possess, so as to enable you to imitate your
Brother42! But who is there that is bold enough to
form an estimate on these points, if he is to be
judged by you, and, more especially, if you are
challenged to do so? For the case of those who
merely publish their works is very different from that
of those who expressly dedicate them to you. In the
former case I might say, Emperor! why do you read
these things? They are written only for the common
people, for farmers or mechanics, or for those who
have nothing else to do; why do you trouble yourself
with them? Indeed, when I undertook this work, I
did not expect that you would sit in judgement upon
me43; I considered your situation much too elevated
for you to descend to such an office. Besides, we
possess the right of openly rejecting the opinion of
men of learning. M. Tullius himself, whose genius is
beyond all competition, uses this privilege; and,
remarkable as it may appear, employs an advocate in
his own defence:—“I do not write for very learned
people; I do not wish my works to be read by Manius
Persius, but by Junius Congus44.” And if Lucilius, who
first introduced the satirical style45, applied such a
remark to himself, and if Cicero thought proper to
borrow it, and that more especially in his treatise “De
Republica,” how much reason have I to do so, who
have such a judge to defend myself against! And by
this dedication I have deprived myself of the benefit
of challenge46; for it is a very different thing whether
a person has a judge given him by lot, or whether he
voluntarily selects one; and we always make more
preparation for an invited guest, than for one that
comes in unexpectedly.
When the candidates for office, during the heat of
the canvass, deposited the fine47 in the hands of
Cato, that determined opposer of bribery, rejoicing as
he did in his being rejected from what he considered
to be foolish honours, they professed to do this out
of respect to his integrity; the greatest glory which a
man could attain. It was on this occasion that Cicero
uttered the noble ejaculation, “How happy are you,
Marcus Porcius, of whom no one dares to ask what is
dishonourable48!” When L. Scipio Asiaticus appealed
to the tribunes, among whom was Gracchus, he
expressed full confidence that he should obtain an
acquittal, even from a judge who was his enemy.
Hence it follows, that he who appoints his own judge
must absolutely submit to the decision; this choice is
therefore termed an appeal49.
I am well aware, that, placed as you are in the
highest station, and gifted with the most splendid
eloquence and the most accomplished mind, even
those who come to pay their respects to you, do it
with a kind of veneration: on this account I ought to
be careful that what is dedicated to you should be
worthy of you. But the country people, and, indeed,
some whole nations offer milk to the Gods50, and
those who cannot procure frankincense substitute in
its place salted cakes; for the Gods are not
dissatisfied when they are worshiped by every one to
the best of his ability. But my temerity will appear
the greater by the consideration, that these volumes,
which I dedicate to you, are of such inferior
importance. For they do not admit of the display of
genius, nor, indeed, is mine one of the highest order;
they admit of no excursions, nor orations, nor
discussions, nor of any wonderful adventures, nor
any variety of transactions, nor, from the barrenness
of the matter, of anything particularly pleasant in the
narration, or agreeable to the reader. The nature of
things, and life as it actually exists, are described in
them; and often the lowest department of it; so that,
in very many cases, I am obliged to use rude and
foreign, or even barbarous terms, and these often
require to be introduced by a kind of preface. And,
besides this, my road is not a beaten track, nor one
which the mind is much disposed to travel over.
There is no one among us who has ever attempted
it, nor is there any one individual among the Greeks
who has treated of all the topics. Most of us seek for
nothing but amusement in our studies, while others
are fond of subjects that are of excessive subtilty,
and completely involved in obscurity. My object is to
treat of all those things which the Greeks include in
the Encyclopædia51, which, however, are either not
generally known or are rendered dubious from our
ingenious conceits. And there are other matters
which many writers have given so much in detail that
we quite loathe them. It is, indeed, no easy task to
give novelty to what is old, and authority to what is
new; brightness to what is become tarnished, and
light to what is obscure; to render what is slighted
acceptable, and what is doubtful worthy of our
confidence; to give to all a natural manner, and to
each its peculiar nature. It is sufficiently honourable
and glorious to have been willing even to make the
attempt, although it should prove unsuccessful. And,
indeed, I am of opinion, that the studies of those are
more especially worthy of our regard, who, after
having overcome all difficulties, prefer the useful
office of assisting others to the mere gratification of
giving pleasure; and this is what I have already done
in some of my former works. I confess it surprises
me, that T. Livius, so celebrated an author as he is,
in one of the books of his history of the city from its
origin, should begin with this remark, “I have now
obtained a sufficient reputation, so that I might put
an end to my work, did not my restless mind require
to be supported by employment52.” Certainly he
ought to have composed this work, not for his own
glory, but for that of the Roman name, and of the
people who were the conquerors of all other nations.
It would have been more meritorious to have
persevered in his labours from his love of the work,
than from the gratification which it afforded himself,
and to have accomplished it, not for his own sake,
but for that of the Roman people.
I have included in thirty-six53 books 20,000 topics,
all worthy of attention, (for, as Domitius Piso54 says,
we ought to make not merely books, but valuable
collections,) gained by the perusal of about 2000
volumes, of which a few only are in the hands of the
studious, on account of the obscurity of the subjects,
procured by the careful perusal of 100 select
authors55; and to these I have made considerable
additions of things, which were either not known to
my predecessors, or which have been lately
discovered. Nor can I doubt but that there still
remain many things which I have omitted; for I am a
mere mortal, and one that has many occupations. I
have, therefore, been obliged to compose this work
at interrupted intervals, indeed during the night, so
that you will find that I have not been idle even
during this period. The day I devote to you, exactly
portioning out my sleep to the necessity of my
health, and contenting myself with this reward, that
while we are musing56 on these subjects (according
to the remark of Varro), we are adding to the length
of our lives; for life properly consists in being awake.
In consideration of these circumstances and these
difficulties, I dare promise nothing; but you have
done me the most essential service in permitting me
to dedicate my work to you. Nor does this merely
give a sanction to it, but it determines its value; for
things are often conceived to be of great value,
solely because they are consecrated in temples.
I have given a full account of all your family—your
Father, yourself, and your Brother, in a history of our
own times, beginning where Aufidius Bassus
concludes57. You will ask, Where is it? It has been
long completed and its accuracy confirmed58; but I
have determined to commit the charge of it to my
heirs, lest I should have been suspected, during my
lifetime, of having been unduly influenced by
ambition. By this means I confer an obligation on
those who occupy the same ground with myself; and
also on posterity, who, I am aware, will contend with
me, as I have done with my predecessors.
You may judge of my taste from my having
inserted, in the beginning of my book, the names of
the authors that I have consulted. For I consider it to
be courteous and to indicate an ingenuous modesty,
to acknowledge the sources whence we have derived
assistance, and not to act as most of those have
done whom I have examined. For I must inform you,
that in comparing various authors with each other, I
have discovered, that some of the most grave and of
the latest writers have transcribed, word for word,
from former works, without making any
acknowledgement; not avowedly rivalling them, in
the manner of Virgil, or with the candour of Cicero,
who, in his treatise “De Republica59,” professes to
coincide in opinion with Plato, and in his Essay on
Consolation for his Daughter, says that he follows
Crantor, and, in his Offices60, Panæcius; volumes,
which, as you well know, ought not merely to be
always in our hands, but to be learned by heart. For
it is indeed the mark of a perverted mind and a bad
disposition, to prefer being caught in a theft to
returning what we have borrowed, especially when
we have acquired capital, by usurious interest61.
The Greeks were wonderfully happy in their titles.
One work they called Κηρίον, which means that it
was as sweet as a honeycomb; another Κέρας
Ἀμαλθείας, or Cornu copiæ, so that you might expect
to get even a draught of pigeon’s milk from it62. Then
they have their Flowers, their Muses, Magazines,
Manuals, Gardens, Pictures, and Sketches63, all of
them titles for which a man might be tempted even
to forfeit his bail. But when you enter upon the
works, O ye Gods and Goddesses! how full of
emptiness! Our duller countrymen have merely their
Antiquities, or their Examples, or their Arts. I think
one of the most humorous of them has his Nocturnal
Studies64, a term employed by Bibaculus; a name
which he richly deserved65. Varro, indeed, is not
much behind him, when he calls one of his satires A
Trick and a Half, and another Turning the Tables66.
Diodorus was the first among the Greeks who laid
aside this trifling manner and named his history The
Library67. Apion, the grammarian, indeed—he whom
Tiberius Cæsar called the Trumpeter of the World,
but would rather seem to be the Bell of the Town-
crier68,—supposed that every one to whom he
inscribed any work would thence acquire immortality.
I do not regret not having given my work a more
fanciful title.
That I may not, however, appear to inveigh so
completely against the Greeks, I should wish to be
considered under the same point of view with those
inventors of the arts of painting and sculpture, of
whom you will find an account in these volumes,
whose works, although they are so perfect that we
are never satisfied with admiring them, are inscribed
with a temporary title69, such as “Apelles, or
Polycletus, was doing this;” implying that the work
was only commenced and still imperfect, and that
the artist might benefit by the criticisms that were
made on it and alter any part that required it, if he
had not been prevented by death. It is also a great
mark of their modesty, that they inscribed their
works as if they were the last which they had
executed, and as still in hand at the time of their
death. I think there are but three works of art which
are inscribed positively with the words “such a one
executed this;” of these I shall give an account in the
proper place. In these cases it appears, that the
artist felt the most perfect satisfaction with his work,
and hence these pieces have excited the envy of
every one.
I, indeed, freely admit, that much may be added
to my works; not only to this, but to all which I have
published. By this admission I hope to escape from
the carping critics70, and I have the more reason to
say this, because I hear that there are certain Stoics
and Logicians71, and also Epicureans (from the
Grammarians72 I expected as much), who are big
with something against the little work I published on
Grammar73; and that they have been carrying these
abortions for ten years together—a longer pregnancy
this than the elephant’s74. But I well know, that even
a woman once wrote against Theophrastus, a man
so eminent for his eloquence that he obtained his
name, which signifies the Divine speaker75, and that
from this circumstance originated the proverb of
choosing a tree to hang oneself76.
I cannot refrain from quoting the words of Cato
the censor, which are so pertinent to this point. It
appears from them, that even Cato, who wrote
commentaries on military discipline77, and who had
learned the military art under Africanus, or rather
under Hannibal (for he could not endure Africanus78,
who, when he was his general, had borne away the
triumph from him), that Cato, I say, was open to the
attacks of such as caught at reputation for
themselves by detracting from the merits of others.
And what does he say in his book? “I know, that
when I shall publish what I have written, there will
be many who will do all they can to depreciate it,
and, especially, such as are themselves void of all
merit; but I let their harangues glide by me.” Nor
was the remark of Plancus79 a bad one, when Asinius
Pollio80 was said to be preparing an oration against
him, which was to be published either by himself or
his children, after the death of Plancus, in order that
he might not be able to answer it: “It is only ghosts
that fight with the dead.” This gave such a blow to
the oration, that in the opinion of the learned
generally, nothing was ever thought more
scandalous. Feeling myself, therefore, secure against
these vile slanderers81, a name elegantly composed
by Cato, to express their slanderous and vile
disposition (for what other object have they, but to
wrangle and breed quarrels?), I will proceed with my
projected work.
And because the public good requires that you
should be spared as much as possible from all
trouble, I have subjoined to this epistle the contents
of each of the following books82, and have used my
best endeavours to prevent your being obliged to
read them all through. And this, which was done for
your benefit, will also serve the same purpose for
others, so that any one may search for what he
wishes, and may know where to find it. This has
been already done among us by Valerius Soranus, in
his work which he entitled “On Mysteries83.”
The 1st book is the Preface of the Work, dedicated
to Titus Vespasian Cæsar.
The 2nd is on the World, the Elements, and the
Heavenly Bodies84.
The 3rd, 4th, 5th and 6th books are on Geography,
in which is contained an account of the situation of
the different countries, the inhabitants, the seas,
towns, harbours, mountains, rivers, and dimensions,
and the various tribes, some of which still exist and
others have disappeared.
The 7th is on Man, and the Inventions of Man.
The 8th on the various kinds of Land Animals.
The 9th on Aquatic Animals.
The 10th on the various kinds of Birds.
The 11th on Insects.
The 12th on Odoriferous Plants.
The 13th on Exotic Trees.
The 14th on Vines.
The 15th on Fruit Trees.
The 16th on Forest Trees.
The 17th on Plants raised in nurseries or gardens.
The 18th on the nature of Fruits and the Cerealia,
and the pursuits of the Husbandman.
The 19th on Flax, Broom85, and Gardening.
The 20th on the Cultivated Plants that are proper
for food and for medicine.
The 21st on Flowers and Plants that are used for
making Garlands.
The 22nd on Garlands, and Medicines made from
Plants.
The 23rd on Medicines made from Wine and from
cultivated Trees.
The 24th on Medicines made from Forest Trees.
The 25th on Medicines made from Wild Plants.
The 26th on New Diseases, and Medicines made,
for certain Diseases, from Plants.
The 27th on some other Plants and Medicines.
The 28th on Medicines procured from Man and
from large Animals.
The 29th on Medical Authors, and on Medicines
from other Animals.
The 30th on Magic, and Medicines for certain parts
of the Body.
The 31st on Medicines from Aquatic Animals.
The 32nd on the other properties of Aquatic
Animals.
The 33rd on Gold and Silver.
The 34th on Copper and Lead, and the workers of
Copper.
The 35th on Painting, Colours, and Painters.

You might also like