SlideShare a Scribd company logo
Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.com
PostgreSQL Server Programming - Second Edition Dar
https://textbookfull.com/product/postgresql-server-
programming-second-edition-dar/
OR CLICK BUTTON
DOWNLOAD NOW
Explore and download more ebook at https://textbookfull.com
Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.
Learn PostgreSQL - Second Edition -.-
https://textbookfull.com/product/learn-postgresql-second-edition/
textboxfull.com
PostgreSQL 9 Administration Cookbook - Second Edition
Simon Riggs
https://textbookfull.com/product/postgresql-9-administration-cookbook-
second-edition-simon-riggs/
textboxfull.com
DaR Darverius House of DaR 1 1st Edition Jennifer Julie
Miller
https://textbookfull.com/product/dar-darverius-house-of-dar-1-1st-
edition-jennifer-julie-miller/
textboxfull.com
PostgreSQL High Availability Cookbook Master over 100
recipes to design and implement a highly available server
with the advanced features of PostgreSQL 2nd Edition Shaun
M. Thomas
https://textbookfull.com/product/postgresql-high-availability-
cookbook-master-over-100-recipes-to-design-and-implement-a-highly-
available-server-with-the-advanced-features-of-postgresql-2nd-edition-
shaun-m-thomas/
textboxfull.com
Windows Server 2016 cookbook Second Edition Krause
https://textbookfull.com/product/windows-server-2016-cookbook-second-
edition-krause/
textboxfull.com
Hands-on Microsoft Windows Server 2016 Second Edition.
Edition Palmer
https://textbookfull.com/product/hands-on-microsoft-windows-
server-2016-second-edition-edition-palmer/
textboxfull.com
Procedural Programming with PostgreSQL PL/pgSQL: Design
Complex Database-Centric Applications with PL/pgSQL 1st
Edition Baji Shaik
https://textbookfull.com/product/procedural-programming-with-
postgresql-pl-pgsql-design-complex-database-centric-applications-with-
pl-pgsql-1st-edition-baji-shaik/
textboxfull.com
Learn Python Programming Second Edition Fabrizio Romano
https://textbookfull.com/product/learn-python-programming-second-
edition-fabrizio-romano/
textboxfull.com
Foundations of Programming Languages Second Edition Lee
https://textbookfull.com/product/foundations-of-programming-languages-
second-edition-lee/
textboxfull.com
Get PostgreSQL Server Programming - Second Edition Dar free all chapters
Get PostgreSQL Server Programming - Second Edition Dar free all chapters
Table of Contents
PostgreSQL Server Programming Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. What Is a PostgreSQL Server?
Why program in the server?
Using PL/pgSQL for integrity checks
About this book's code examples
Switching to the expanded display
Moving beyond simple functions
Data comparisons using operators
Managing related data with triggers
Auditing changes
Data cleaning
Custom sort orders
Programming best practices
KISS – keep it simple stupid
DRY – don't repeat yourself
YAGNI – you ain't gonna need it
SOA – service-oriented architecture
Type extensibility
Caching
Wrapping up – why program in the server?
Performance
Ease of maintenance
Improved productivity
Simple ways to tighten security
Summary
2. Server Programming Environments
Cost of acquisition
Availability of developers
Licensing
Predictability
Community
Procedural languages
Third-party tools
Platform compatibility
Application design
Databases are considered harmful
Encapsulation
What does PostgreSQL offer?
Data locality
More basics
Transactions
General error reporting and error handling
User-defined functions
Other parameters
More control
Summary
3. Your First PL/pgSQL Function
Why PL/pgSQL?
The structure of a PL/pgSQL function
Accessing function arguments
Conditional expressions
Loops with counters
Statement termination
Looping through query results
PERFORM versus SELECT
Looping Through Arrays
Returning a record
Acting on the function's results
Summary
4. Returning Structured Data
Sets and arrays
Returning sets
Returning a set of integers
Using a set returning function
Functions based on views
OUT parameters and records
OUT parameters
Returning records
Using RETURNS TABLE
Returning with no predefined structure
Returning SETOF ANY
Variadic argument lists
A summary of the RETURN SETOF variants
Returning cursors
Iterating over cursors returned from another function
Wrapping up of functions returning cursors
Other ways to work with structured data
Complex data types for the modern world – XML and JSON
XML data type and returning data as XML from functions
Returning data in the JSON format
Summary
5. PL/pgSQL Trigger Functions
Creating the trigger function
Creating the trigger
Working on a simple "Hey, I'm called" trigger
The audit trigger
Disallowing DELETE
Disallowing TRUNCATE
Modifying the NEW record
The timestamping trigger
The immutable fields trigger
Controlling when a trigger is called
Conditional triggers
Triggers on specific field changes
Visibility
Most importantly – use triggers cautiously!
Variables passed to the PL/pgSQL TRIGGER function
Summary
6. PostgreSQL Event Triggers
Use cases for creating event triggers
Creating event triggers
Creating an audit trail
Preventing schema changes
A roadmap of event triggers
Summary
7. Debugging PL/pgSQL
Manual debugging with RAISE NOTICE
Throwing exceptions
Logging to a file
The advantages of RAISE NOTICE
The disadvantages of RAISE NOTICE
Visual debugging
Installing the debugger
Installing the debugger from the source
Installing pgAdmin3
Using the debugger
The advantages of the debugger
The disadvantages of the debugger
Summary
8. Using Unrestricted Languages
Are untrusted languages inferior to trusted ones?
Can you use untrusted languages for important functions?
Will untrusted languages corrupt the database?
Why untrusted?
Why PL/Python?
Quick introduction to PL/Python
A minimal PL/Python function
Data type conversions
Writing simple functions in PL/Python
A simple function
Functions returning a record
Table functions
Running queries in the database
Running simple queries
Using prepared queries
Caching prepared queries
Writing trigger functions in PL/Python
Exploring the inputs of a trigger
A log trigger
Constructing queries
Handling exceptions
Atomicity in Python
Debugging PL/Python
Using plpy.notice() to track the function's progress
Using assert
Redirecting sys.stdout and sys.stderr
Thinking out of the "SQL database server" box
Generating thumbnails when saving images
Sending an e-mail
Listing directory contents
Summary
9. Writing Advanced Functions in C
The simplest C function – return (a + b)
add_func.c
Version 0 call conventions
Makefile
CREATE FUNCTION add(int, int)
add_func.sql.in
Summary for writing a C function
Adding functionality to add(int, int)
Smart handling of NULL arguments
Working with any number of arguments
Basic guidelines for writing C code
Memory allocation
Use palloc() and pfree()
Zero-fill the structures
Include files
Public symbol names
Error reporting from C functions
"Error" states that are not errors
When are messages sent to the client?
Running queries and calling PostgreSQL functions
A sample C function using SPI
Visibility of data changes
More info on SPI_* functions
Handling records as arguments or returned values
Returning a single tuple of a complex type
Extracting fields from an argument tuple
Constructing a return tuple
Interlude – what is Datum?
Returning a set of records
Fast capturing of database changes
Doing something at commit/rollback
Synchronizing between backends
Writing functions in C++
Additional resources for C
Summary
10. Scaling Your Database with PL/Proxy
Creating a simple single-server chat
Dealing with success – splitting tables over multiple databases
What expansion plans work and when?
Moving to a bigger server
Master-slave replication – moving reads to slave
Multimaster replication
Data partitioning across multiple servers
Splitting the data
PL/Proxy – the partitioning language
Installing PL/Proxy
The PL/Proxy language syntax
CONNECT, CLUSTER, and RUN ON
SELECT and TARGET
SPLIT – distributing array elements over several partitions
The distribution of data
Configuring the PL/Proxy cluster using functions
Configuring the PL/Proxy cluster using SQL/MED
Moving data from the single to the partitioned database
Connection Pooling
Summary
11. PL/Perl – Perl Procedural Language
When to use PL/Perl
Installing PL/Perl
A simple PL/Perl function
Passing and returning non-scalar types
Writing PL/Perl triggers
Untrusted Perl
Summary
12. PL/Tcl – Tcl Procedural Language
Installing PL/Tcl
A simple PL/Tcl function
Null checking with Strict functions
The parameter format
Passing and returning arrays
Passing composite-type arguments
Accessing databases
Writing PL/Tcl triggers
Untrusted Tcl
Summary
13. Publishing Your Code as PostgreSQL Extensions
When to create an extension
Unpackaged extensions
Extension versions
The .control file
Building an extension
Installing an extension
Viewing extensions
Publishing your extension
Introduction to PostgreSQL Extension Network
Signing up to publish your extension
Creating an extension project the easy way
Providing the metadata about the extension
Writing your extension code
Creating the package
Submitting the package to PGXN
Installing an extension from PGXN
Summary
14. PostgreSQL as an Extensible RDBMS
What can't be extended?
Creating a new operator
Overloading an operator
Optimizing operators
COMMUTATOR
NEGATOR
Creating index access methods
Creating user-defined aggregates
Using foreign data wrappers
Summary
Index
PostgreSQL Server
Programming Second Edition
PostgreSQL Server
Programming Second Edition
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored
in a retrieval system, or transmitted in any form or by any means,
without the prior written permission of the publisher, except in the
case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure
the accuracy of the information presented. However, the information
contained in this book is sold without warranty, either express or
implied. Neither the authors, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or
alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information
about all of the companies and products mentioned in this book by
the appropriate use of capitals. However, Packt Publishing cannot
guarantee the accuracy of this information.
First published: June 2013
Second edition: February 2015
Production reference: 1210215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-058-1
www.packtpub.com
Credits
Authors
Usama Dar
Hannu Krosing
Jim Mlodgenski
Kirk Roybal
Reviewers
Stephen Frost
Rick van Hattem
Vibhor Kumar
Jeff Lawson
Mariano Reingart
Julien Tachoires
Commissioning Editor
Usha Iyer
Acquisition Editors
Antony Lowe
Meeta Rajani
Sam Wood
Content Development Editor
Adrian Raposo
Technical Editors
Mrunmayee Patil
Chinmay Puranik
Copy Editors
Dipti Kapadia
Aarti Saldanha
Project Coordinator
Kinjal Bari
Proofreaders
Maria Gould
Linda Morris
Indexer
Monica Ajmera Mehta
Production Coordinator
Nitesh Thakur
Cover Work
Nitesh Thakur
About the Authors
Usama Dar is a seasoned software developer and architect. During
his 14 years' career, he has worked extensively with PostgreSQL and
other database technologies. He worked on PostgreSQL internals
extensively while he was working for EnterpriseDB. Currently, he
lives in Munich where he works for Huawei's European Research
Center. He designs the next generation of high-performance
database systems based on open source technologies, such as
PostgreSQL, which are used under high workloads and strict
performance requirements.
Hannu Krosing was a PostgreSQL user before it was rewritten to
use SQL as its main query language in 1995. Therefore, he has both
the historic perspective of its development, as well as almost 20
years of experience in using it to solve various real-life problems.
He was the first database administrator and database architect at
Skype, where he invented the sharding language PL/Proxy that
allows you to scale the user database in order to work with billions
of users.
After he left Skype at the end of 2006—about a year after it was
bought by eBay—he has been working as a PostgreSQL consultant
with 2ndQuadrant, the premier PostgreSQL consultancy with a global
reach and local presence in most parts of the world.
He has coauthored PostgreSQL 9 Administration Cookbook, Packt
Publishing, together with one of the main PostgreSQL developers,
Simon Riggs.
I want to sincerely thank my wife, Evelyn, for her support while
writing this book.
Jim Mlodgenski is the CTO of OpenSCG, a professional services
company focused on leveraging open source technologies for
strategic advantage. He was formerly the CEO of StormDB, a
database cloud company focused on horizontal scalability. Prior to
StormDB, he has held highly technical roles at Cirrus Technology,
Inc., EnterpriseDB, and Fusion Technologies.
Jim is also a fervent advocate of PostgreSQL. He is on the board of
the United States PostgreSQL Association as well as a part of the
organizing teams of the New York PostgreSQL User Group and
Philadelphia PostgreSQL User Group.
Kirk Roybal has been an active member of the PostgreSQL
community since 1998. He has helped organize user groups in
Houston, Dallas, and Bloomington, IL. He has mentored many junior
database administrators and provided cross-training to senior
database engineers. He has provided solutions using PostgreSQL for
reporting, business intelligence, data warehousing, applications, and
development support.
He saw the scope of PostgreSQL when his first small-scale business
customer asked for a web application. At that time, competitive
database products were either extremely immature or cost
prohibitive.
Kirk has stood by his choice of PostgreSQL for many years now. His
expertise is founded on keeping up with features and capabilities as
they become available.
Writing a book has been a unique experience for me. Many
people fantasize about it, few start one, and even fewer get to
publication. I am proud to be part of a team that actually made it
to the book shelf (which itself is a diminishing breed). Thanks to
Sarah Cullington from Packt Publishing for giving me a chance to
participate in the project. I believe that the PostgreSQL
community will be better served by this information, and I hope
that they receive this as a reward for the time that they have
invested in me over the years.
A book only has the value that the readers give it. Thank you to
the PostgreSQL community for all the technical, personal, and
professional development help you have provided. The
PostgreSQL community is a great bunch of people, and I have
enjoyed the company of many of them. I hope to contribute
more to this project in the future, and I hope you find my
contributions as valuable as I find yours.
Thank you to my family for giving me a reason to succeed and
for listening to the gobbledygook and nodding appreciatively.
Have you ever had your family ask you what you were doing and
answered them with a function? Try it. No, then again, don't try
it. They may just have you involuntarily checked in somewhere.
About the Reviewers
Stephen Frost is a major contributor and committer to PostgreSQL,
who has been involved with PostgreSQL since 2002, and has
developed features such as the role system and column-level
privileges.
He is the chief technology officer at Crunchy Data Solutions, Inc., the
PostgreSQL company for Secure Enterprises. He is involved in the
advancement of PostgreSQL's capabilities, particularly in the area of
security in order to support the needs of government and financial
institutions who have strict security and regulatory requirements.
Rick van Hattem is an entrepreneur with a computer science
background and a long-time open source developer with vast
experience in the C, C++, Python, and Java languages. Additionally,
he has worked with most large database servers such as Oracle, MS
SQL, and MySQL, but he has been focusing on PostgreSQL since
Version 7.4.
He is one of the founders of the Fashiolista.com social network, and
until recently, he was the CTO. Here, he used PostgreSQL to scale
the feeds for millions of users to show that PostgreSQL can hold up
to NoSQL solutions, given some tuning and additional tools. After
Fashiolista, he worked as a freelance consultant for several
companies, including 2ndQuadrant.
He is currently the founder of PGMon.com, a monitoring service that
analyzes your databases, indexes, and queries to keep them running
at peak performance. In addition to analyzing your database
settings, the system actively monitors your queries and gives you
recommendations to enhance performance.
He is also the creator and maintainer of a large number of open
source projects, such as pg_query_analyser, pg_cascade_timestamp,
QtQuery, Python-Statsd, and Django-Statsd.
Vibhor Kumar is a principal system architect at EnterpriseDB who
specializes in assisting Fortune 100 companies to deploy, manage,
and optimize Postgres databases. He joined EnterpriseDB in 2008 to
work with Postgres after several years of working with Oracle
systems. He has worked in team leadership roles at IBM Global
Services and BMC Software as well as an Oracle database
administrator at CMC Ltd. for several years. He has developed
expertise in Oracle, DB2, and MongoDB and holds certifications in
them. He has experience working with MS SQL Server, MySQL, and
data warehousing. He holds a bachelor's degree in computer science
from the University of Lucknow and a master's degree in computer
science from the Army Institute of Management, Kolkata. He is a
certified PostgreSQL trainer and holds a professional certification in
Postgres Plus Advanced Server from EnterpriseDB.
Jeff Lawson has been a fan and user of PostgreSQL since the time
he discovered it in 2001. Over the years, he has also developed and
deployed applications for IBM DB2, Oracle, MySQL, Microsoft SQL
Server, Sybase, and others, but he always prefers PostgreSQL for its
balance of features and openness. Much of his experience involves
developing for Internet-facing websites/projects that require highly
scalable databases with high availability or with provisions for
disaster recovery.
He currently works as the director of software development for
FlightAware, which is an airplane-tracking website that uses
PostgreSQL and other open source software to store and analyze the
positions of the thousands of flights that are operated worldwide
every day. He has extensive experience in software architecture,
data security, and network protocol design from the software
engineering positions he has held at Univa / United Devices,
Microsoft, NASA's Jet Propulsion Laboratory, and WolfeTech. He is a
founder of distributed.net, which pioneered distributed computing in
the 1990s, and he continues to serve as the chief of operations and
as a member of the board there. He earned a BSc degree in
computer science from Harvey Mudd College.
He is fond of cattle, holds an FAA private pilot certificate, and owns
an airplane based in Houston, Texas.
Mariano Reingart lives in Buenos Aires, Argentina, and is a
specialist in the software development of applications and libraries
(web services, PDF, GUI, replication, and so on) with more than 10
years of experience. Currently, he is the PostgreSQL regional contact
for Argentina and a Python Software Foundation member.
He is a major contributor to the web2py Python web framework, and
now he's working on the wxWidgets multiplatform GUI toolkit
(specifically in the Qt port and Android mobile areas). Also, he has
contributed to more than a dozen open source projects, including an
interface for Free Electronic Invoice web services (PyAfipWs) and
Pythonic replication for PostgreSQL (PyReplica).
He has a bachelor's degree in computer systems analysis, and
currently, he's a master's candidate for the MSc in free software
degree at the Open University of Catalonia.
He works on his own funded entrepreneurial venture formed by an
open group of independent professionals, dedicated to software
development, training, and technical support, focusing on open
source tools (GNU/Linux, Python, PostgreSQL, and
web2py/wxPython).
He has worked for local Python-based companies in large business
applications (ERP, SCM, and CRM) and mission critical systems
(election counting, electronic voting, and 911 emergency events
support). He has contributed to books such as web2py Enterprise
Web Framework, Third Edition, and web2py Application
Development Cookbook, Packt Publishing, and several Spanish
translations of the PostgreSQL official documentation.
His full resume is available at
http://reingart.blogspot.com/p/resume.html.
Julien Tachoires is a PostgreSQL specialist, who works as
consultant for the French PostgreSQL company Dalibo. He is the
main developer of pg_activity, a top-end software dedicated to
follow the PostgreSQL incoming traffic in real time, which is written
in Python.
I want to thank my employer Dalibo; my wife, Camille; and my
son, Arthur.
www.PacktPub.com
Support files, eBooks,
discount offers, and more
For support files and downloads related to your book, please visit
www.PacktPub.com.
Did you know that Packt offers eBook versions of every book
published, with PDF and ePub files available? You can upgrade to the
eBook version at www.PacktPub.com and as a print book customer,
you are entitled to a discount on the eBook copy. Get in touch with
us at <service@packtpub.com> for more details.
At www.PacktPub.com, you can also read a collection of free
technical articles, sign up for a range of free newsletters and receive
exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is
Packt's online digital book library. Here, you can search, access, and
read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Free access for Packt account
holders
If you have an account with Packt at www.PacktPub.com, you can
use this to access PacktLib today and view 9 entirely free books.
Simply use your login credentials for immediate access.
Preface
This fascinating guide to server programming will take your skills of
PostgreSQL to a whole new level. A step-by-step approach with
illuminating examples will educate you about the full range of
possibilities. You will understand the extension framework of
PostgreSQL and leverage it in ways you haven't even invented yet.
You will learn how to write functions and create your own data
types, all in your favorite programming language. It is a step-by-step
tutorial, with plenty of tips and tricks to kick-start server
programming.
What this book covers
Chapter 1, What Is a PostgreSQL Server?, introduces you to the
PostgreSQL server and will set the tone for the rest of the book. It
introduces you to the ways in which a PostgreSQL server is
extendible, and shows you that it can be treated as a complete
software development framework instead of just a database server.
Chapter 2, Server Programming Environments, elaborates that
PostgreSQL is built to handle user needs, but more importantly, it is
built not to change underneath users in the future. It will touch upon
the environments and will highlight some of the important things to
be kept in mind when programming on the server in PostgreSQL.
Chapter 3, Your First PL/pgSQL Function, builds the foundations by
demonstrating how to write simple PL/pgSQL functions.
Chapter 4, Returning Structured Data, builds on the knowledge of
writing PL/pgSQL functions and demonstrates how to write functions
that return a set of values such as rows, arrays, and cursors.
Chapter 5, PL/pgSQL Trigger Functions, discusses how to write
PL/pgSQL functions that are used to write trigger logic. It also
discusses the various types of triggers available in PostgreSQL and
the options that a database developer has when writing such
functions.
Chapter 6, PostgreSQL Event Triggers, discusses PostgreSQL's event
trigger functionality. Event triggers are fired when running a DDL
operation on a table. This chapter discusses the various possibilities
and options of creating event triggers and their limitations in
PostgreSQL.
Chapter 7, Debugging PL/pgSQL, elaborates on how to debug
PL/pgSQL's stored procedures and functions in PostgreSQL. This
chapter explains how to install the debugger plugin and use the
pgAdmin debugger console.
Chapter 8, Using Unrestricted Languages, explains the differences
between restricted and unrestricted PostgreSQL languages. This
chapter uses PL/Python as an example and demonstrates the
examples of both restricted and unrestricted functions in PL/Python.
Chapter 9, Writing Advanced Functions in C, explains how to extend
PostgreSQL by writing user-defined functions (UDFs) in C.
Chapter 10, Scaling Your Database with PL/Proxy, explains the use
of a special programming language in PostgreSQL called PL/Proxy
and how to use it in order to partition and shard your database.
Chapter 11, PL/Perl – Perl Procedural Language, discusses a popular
PL language in PostgreSQL called PL/Perl. This chapter uses some
simple examples to demonstrate how you can use Perl to write
database functions.
Chapter 12, PL/Tcl – Tcl Procedural Language, discusses Tcl as a
language of choice when writing database functions. It discusses the
pros and cons of using Tcl in the database.
Chapter 13, Publishing Your Code as PostgreSQL Extensions,
discusses how to package and distribute the PostgreSQL extensions.
Well-packaged extensions can be easily distributed and installed by
other users. This chapter also introduces you to the PostgreSQL
Extension Network (PGXN) and shows you how to use it to get the
extensions published by other developers.
Chapter 14, PostgreSQL as an Extensible RDBMS, discusses more
extensibility options in PostgreSQL, such as creating new data types,
operators, and index methods.
What you need for this book
In order to follow this book, you need the following software:
PostgreSQL Database Server 9.4
Linux/Unix Operating System
Python 2, Perl, and Tcl
Who this book is for
This book is for moderate to advanced level PostgreSQL database
professionals. To get a better understanding of this book, you should
have a general experience in writing SQL, a basic idea of query
tuning, and some coding experience in a language of your choice.
Conventions
In this book, you will find a number of text styles that distinguish
between different kinds of information. Here are some examples of
these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames,
file extensions, pathnames, dummy URLs, user input, and Twitter
handles are shown as follows: "If any of the checks fail, you should
do ROLLBACK instead of COMMIT."
A block of code is set as follows:
CREATE TABLE accounts(owner text,
balance numeric, amount numeric);
INSERT INTO accounts VALUES
('Bob',100);
INSERT INTO accounts VALUES
('Mary',200);
When we wish to draw your attention to a particular part of a code
block, the relevant lines or items are set in bold:
CREATE OR REPLACE FUNCTION
fibonacci_seq(num integer)
RETURNS SETOF integer AS $$
DECLARE
a int := 0;
b int := 1;
BEGIN
IF (num <= 0)
THEN RETURN;
END IF;
Another Random Scribd Document
with Unrelated Content
*** END OF THE PROJECT GUTENBERG EBOOK CHRONIQUES DE J.
FROISSART, TOME 07/13 ***
Updated editions will replace the previous one—the old editions
will be renamed.
Creating the works from print editions not protected by U.S.
copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.
START: FULL LICENSE
THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK
To protect the Project Gutenberg™ mission of promoting the
free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.
Section 1. General Terms of Use and
Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.
1.B. “Project Gutenberg” is a registered trademark. It may only
be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E. Unless you have removed all references to Project
Gutenberg:
1.E.1. The following sentence, with active links to, or other
immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.
1.E.2. If an individual Project Gutenberg™ electronic work is
derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.
1.E.3. If an individual Project Gutenberg™ electronic work is
posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.
1.E.4. Do not unlink or detach or remove the full Project
Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute
this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
1.E.7. Do not charge a fee for access to, viewing, displaying,
performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.
1.E.8. You may charge a reasonable fee for copies of or
providing access to or distributing Project Gutenberg™
electronic works provided that:
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You provide a full refund of any money paid by a user who
notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.
• You provide, in accordance with paragraph 1.F.3, a full refund of
any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.E.9. If you wish to charge a fee or distribute a Project
Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.
1.F.
1.F.1. Project Gutenberg volunteers and employees expend
considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.
1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except
for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.
1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you
discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.
1.F.4. Except for the limited right of replacement or refund set
forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
1.F.5. Some states do not allow disclaimers of certain implied
warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.
1.F.6. INDEMNITY - You agree to indemnify and hold the
Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.
Section 2. Information about the Mission
of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.
Volunteers and financial support to provide volunteers with the
assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.
Section 3. Information about the Project
Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.
The Foundation’s business office is located at 809 North 1500
West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.
The Foundation is committed to complying with the laws
regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.
While we cannot and do not solicit contributions from states
where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.
International donations are gratefully accepted, but we cannot
make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.
Please check the Project Gutenberg web pages for current
donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.
Section 5. General Information About
Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.
Project Gutenberg™ eBooks are often created from several
printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
This website includes information about Project Gutenberg™,
including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
textbookfull.com

More Related Content

Similar to Get PostgreSQL Server Programming - Second Edition Dar free all chapters (20)

PDF
Learning postgresql
DAVID RAUDALES
 
PDF
PostgreSQL - Case Study
S.Shayan Daneshvar
 
PDF
0292-introduction-postgresql.pdf
Mustafa Keskin
 
PDF
Plpgsql russia-pgconf
Pavel Stěhule
 
PDF
Bn 1016 demo postgre sql-online-training
conline training
 
PDF
Building a Complex, Real-Time Data Management Application
Jonathan Katz
 
PDF
Postgresql v15.1
Banking at Ho Chi Minh city
 
PPTX
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
MhmdMk10
 
PDF
9.6_Course Material-Postgresql_002.pdf
sreedb2
 
PDF
Business logic with PostgreSQL and Python
Hubert Piotrowski
 
ODP
Introduction to PostgreSQL
Jim Mlodgenski
 
PDF
Postgresql v14.6 Document Guide
Banking at Ho Chi Minh city
 
PDF
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
PDF
Whats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Citus Data
 
PDF
postgresql 16.3(latest version) 2024-25.pdf
ayaankim007
 
PPTX
PostgreSQL- An Introduction
Smita Prasad
 
PPTX
PL/pgSQL - An Introduction on Using Imperative Programming in PostgreSQL
Reactive.IO
 
PDF
PostgreSQL 9 Administration Cookbook - Second Edition Simon Riggs
mowwoiq538
 
PDF
Migration From Oracle to PostgreSQL
PGConf APAC
 
PDF
Introduction to oracle 9i pl sql - part 2
Manaswi Sharma
 
Learning postgresql
DAVID RAUDALES
 
PostgreSQL - Case Study
S.Shayan Daneshvar
 
0292-introduction-postgresql.pdf
Mustafa Keskin
 
Plpgsql russia-pgconf
Pavel Stěhule
 
Bn 1016 demo postgre sql-online-training
conline training
 
Building a Complex, Real-Time Data Management Application
Jonathan Katz
 
Postgresql v15.1
Banking at Ho Chi Minh city
 
Chjkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjj01_The Basics.pptx
MhmdMk10
 
9.6_Course Material-Postgresql_002.pdf
sreedb2
 
Business logic with PostgreSQL and Python
Hubert Piotrowski
 
Introduction to PostgreSQL
Jim Mlodgenski
 
Postgresql v14.6 Document Guide
Banking at Ho Chi Minh city
 
Beyond Postgres: Interesting Projects, Tools and forks
Sameer Kumar
 
Whats wrong with postgres | PGConf EU 2019 | Craig Kerstiens
Citus Data
 
postgresql 16.3(latest version) 2024-25.pdf
ayaankim007
 
PostgreSQL- An Introduction
Smita Prasad
 
PL/pgSQL - An Introduction on Using Imperative Programming in PostgreSQL
Reactive.IO
 
PostgreSQL 9 Administration Cookbook - Second Edition Simon Riggs
mowwoiq538
 
Migration From Oracle to PostgreSQL
PGConf APAC
 
Introduction to oracle 9i pl sql - part 2
Manaswi Sharma
 

Recently uploaded (20)

PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Controller Request and Response in Odoo18
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Quarter 1_PPT_PE & HEALTH 8_WEEK 3-4.pptx
ronajadolpnhs
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
QUARTER 1 WEEK 2 PLOT, POV AND CONFLICTS
KynaParas
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Ad

Get PostgreSQL Server Programming - Second Edition Dar free all chapters

  • 1. Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.com PostgreSQL Server Programming - Second Edition Dar https://textbookfull.com/product/postgresql-server- programming-second-edition-dar/ OR CLICK BUTTON DOWNLOAD NOW Explore and download more ebook at https://textbookfull.com
  • 2. Recommended digital products (PDF, EPUB, MOBI) that you can download immediately if you are interested. Learn PostgreSQL - Second Edition -.- https://textbookfull.com/product/learn-postgresql-second-edition/ textboxfull.com PostgreSQL 9 Administration Cookbook - Second Edition Simon Riggs https://textbookfull.com/product/postgresql-9-administration-cookbook- second-edition-simon-riggs/ textboxfull.com DaR Darverius House of DaR 1 1st Edition Jennifer Julie Miller https://textbookfull.com/product/dar-darverius-house-of-dar-1-1st- edition-jennifer-julie-miller/ textboxfull.com PostgreSQL High Availability Cookbook Master over 100 recipes to design and implement a highly available server with the advanced features of PostgreSQL 2nd Edition Shaun M. Thomas https://textbookfull.com/product/postgresql-high-availability- cookbook-master-over-100-recipes-to-design-and-implement-a-highly- available-server-with-the-advanced-features-of-postgresql-2nd-edition- shaun-m-thomas/ textboxfull.com
  • 3. Windows Server 2016 cookbook Second Edition Krause https://textbookfull.com/product/windows-server-2016-cookbook-second- edition-krause/ textboxfull.com Hands-on Microsoft Windows Server 2016 Second Edition. Edition Palmer https://textbookfull.com/product/hands-on-microsoft-windows- server-2016-second-edition-edition-palmer/ textboxfull.com Procedural Programming with PostgreSQL PL/pgSQL: Design Complex Database-Centric Applications with PL/pgSQL 1st Edition Baji Shaik https://textbookfull.com/product/procedural-programming-with- postgresql-pl-pgsql-design-complex-database-centric-applications-with- pl-pgsql-1st-edition-baji-shaik/ textboxfull.com Learn Python Programming Second Edition Fabrizio Romano https://textbookfull.com/product/learn-python-programming-second- edition-fabrizio-romano/ textboxfull.com Foundations of Programming Languages Second Edition Lee https://textbookfull.com/product/foundations-of-programming-languages- second-edition-lee/ textboxfull.com
  • 6. Table of Contents PostgreSQL Server Programming Second Edition Credits About the Authors About the Reviewers www.PacktPub.com Support files, eBooks, discount offers, and more Why subscribe? Free access for Packt account holders Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions 1. What Is a PostgreSQL Server? Why program in the server? Using PL/pgSQL for integrity checks About this book's code examples Switching to the expanded display Moving beyond simple functions Data comparisons using operators Managing related data with triggers Auditing changes Data cleaning Custom sort orders Programming best practices KISS – keep it simple stupid
  • 7. DRY – don't repeat yourself YAGNI – you ain't gonna need it SOA – service-oriented architecture Type extensibility Caching Wrapping up – why program in the server? Performance Ease of maintenance Improved productivity Simple ways to tighten security Summary 2. Server Programming Environments Cost of acquisition Availability of developers Licensing Predictability Community Procedural languages Third-party tools Platform compatibility Application design Databases are considered harmful Encapsulation What does PostgreSQL offer? Data locality More basics Transactions General error reporting and error handling User-defined functions Other parameters More control Summary 3. Your First PL/pgSQL Function Why PL/pgSQL? The structure of a PL/pgSQL function Accessing function arguments
  • 8. Conditional expressions Loops with counters Statement termination Looping through query results PERFORM versus SELECT Looping Through Arrays Returning a record Acting on the function's results Summary 4. Returning Structured Data Sets and arrays Returning sets Returning a set of integers Using a set returning function Functions based on views OUT parameters and records OUT parameters Returning records Using RETURNS TABLE Returning with no predefined structure Returning SETOF ANY Variadic argument lists A summary of the RETURN SETOF variants Returning cursors Iterating over cursors returned from another function Wrapping up of functions returning cursors Other ways to work with structured data Complex data types for the modern world – XML and JSON XML data type and returning data as XML from functions Returning data in the JSON format Summary 5. PL/pgSQL Trigger Functions Creating the trigger function Creating the trigger Working on a simple "Hey, I'm called" trigger The audit trigger
  • 9. Disallowing DELETE Disallowing TRUNCATE Modifying the NEW record The timestamping trigger The immutable fields trigger Controlling when a trigger is called Conditional triggers Triggers on specific field changes Visibility Most importantly – use triggers cautiously! Variables passed to the PL/pgSQL TRIGGER function Summary 6. PostgreSQL Event Triggers Use cases for creating event triggers Creating event triggers Creating an audit trail Preventing schema changes A roadmap of event triggers Summary 7. Debugging PL/pgSQL Manual debugging with RAISE NOTICE Throwing exceptions Logging to a file The advantages of RAISE NOTICE The disadvantages of RAISE NOTICE Visual debugging Installing the debugger Installing the debugger from the source Installing pgAdmin3 Using the debugger The advantages of the debugger The disadvantages of the debugger Summary 8. Using Unrestricted Languages Are untrusted languages inferior to trusted ones? Can you use untrusted languages for important functions?
  • 10. Will untrusted languages corrupt the database? Why untrusted? Why PL/Python? Quick introduction to PL/Python A minimal PL/Python function Data type conversions Writing simple functions in PL/Python A simple function Functions returning a record Table functions Running queries in the database Running simple queries Using prepared queries Caching prepared queries Writing trigger functions in PL/Python Exploring the inputs of a trigger A log trigger Constructing queries Handling exceptions Atomicity in Python Debugging PL/Python Using plpy.notice() to track the function's progress Using assert Redirecting sys.stdout and sys.stderr Thinking out of the "SQL database server" box Generating thumbnails when saving images Sending an e-mail Listing directory contents Summary 9. Writing Advanced Functions in C The simplest C function – return (a + b) add_func.c Version 0 call conventions Makefile CREATE FUNCTION add(int, int) add_func.sql.in
  • 11. Summary for writing a C function Adding functionality to add(int, int) Smart handling of NULL arguments Working with any number of arguments Basic guidelines for writing C code Memory allocation Use palloc() and pfree() Zero-fill the structures Include files Public symbol names Error reporting from C functions "Error" states that are not errors When are messages sent to the client? Running queries and calling PostgreSQL functions A sample C function using SPI Visibility of data changes More info on SPI_* functions Handling records as arguments or returned values Returning a single tuple of a complex type Extracting fields from an argument tuple Constructing a return tuple Interlude – what is Datum? Returning a set of records Fast capturing of database changes Doing something at commit/rollback Synchronizing between backends Writing functions in C++ Additional resources for C Summary 10. Scaling Your Database with PL/Proxy Creating a simple single-server chat Dealing with success – splitting tables over multiple databases What expansion plans work and when? Moving to a bigger server Master-slave replication – moving reads to slave Multimaster replication
  • 12. Data partitioning across multiple servers Splitting the data PL/Proxy – the partitioning language Installing PL/Proxy The PL/Proxy language syntax CONNECT, CLUSTER, and RUN ON SELECT and TARGET SPLIT – distributing array elements over several partitions The distribution of data Configuring the PL/Proxy cluster using functions Configuring the PL/Proxy cluster using SQL/MED Moving data from the single to the partitioned database Connection Pooling Summary 11. PL/Perl – Perl Procedural Language When to use PL/Perl Installing PL/Perl A simple PL/Perl function Passing and returning non-scalar types Writing PL/Perl triggers Untrusted Perl Summary 12. PL/Tcl – Tcl Procedural Language Installing PL/Tcl A simple PL/Tcl function Null checking with Strict functions The parameter format Passing and returning arrays Passing composite-type arguments Accessing databases Writing PL/Tcl triggers Untrusted Tcl Summary 13. Publishing Your Code as PostgreSQL Extensions When to create an extension Unpackaged extensions
  • 13. Extension versions The .control file Building an extension Installing an extension Viewing extensions Publishing your extension Introduction to PostgreSQL Extension Network Signing up to publish your extension Creating an extension project the easy way Providing the metadata about the extension Writing your extension code Creating the package Submitting the package to PGXN Installing an extension from PGXN Summary 14. PostgreSQL as an Extensible RDBMS What can't be extended? Creating a new operator Overloading an operator Optimizing operators COMMUTATOR NEGATOR Creating index access methods Creating user-defined aggregates Using foreign data wrappers Summary Index
  • 15. PostgreSQL Server Programming Second Edition Copyright © 2015 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: June 2013 Second edition: February 2015 Production reference: 1210215 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
  • 17. Credits Authors Usama Dar Hannu Krosing Jim Mlodgenski Kirk Roybal Reviewers Stephen Frost Rick van Hattem Vibhor Kumar Jeff Lawson Mariano Reingart Julien Tachoires Commissioning Editor Usha Iyer Acquisition Editors Antony Lowe Meeta Rajani Sam Wood
  • 18. Content Development Editor Adrian Raposo Technical Editors Mrunmayee Patil Chinmay Puranik Copy Editors Dipti Kapadia Aarti Saldanha Project Coordinator Kinjal Bari Proofreaders Maria Gould Linda Morris Indexer Monica Ajmera Mehta Production Coordinator Nitesh Thakur Cover Work Nitesh Thakur
  • 19. About the Authors Usama Dar is a seasoned software developer and architect. During his 14 years' career, he has worked extensively with PostgreSQL and other database technologies. He worked on PostgreSQL internals extensively while he was working for EnterpriseDB. Currently, he lives in Munich where he works for Huawei's European Research Center. He designs the next generation of high-performance database systems based on open source technologies, such as PostgreSQL, which are used under high workloads and strict performance requirements. Hannu Krosing was a PostgreSQL user before it was rewritten to use SQL as its main query language in 1995. Therefore, he has both the historic perspective of its development, as well as almost 20 years of experience in using it to solve various real-life problems. He was the first database administrator and database architect at Skype, where he invented the sharding language PL/Proxy that allows you to scale the user database in order to work with billions of users. After he left Skype at the end of 2006—about a year after it was bought by eBay—he has been working as a PostgreSQL consultant with 2ndQuadrant, the premier PostgreSQL consultancy with a global reach and local presence in most parts of the world. He has coauthored PostgreSQL 9 Administration Cookbook, Packt Publishing, together with one of the main PostgreSQL developers, Simon Riggs. I want to sincerely thank my wife, Evelyn, for her support while writing this book.
  • 20. Jim Mlodgenski is the CTO of OpenSCG, a professional services company focused on leveraging open source technologies for strategic advantage. He was formerly the CEO of StormDB, a database cloud company focused on horizontal scalability. Prior to StormDB, he has held highly technical roles at Cirrus Technology, Inc., EnterpriseDB, and Fusion Technologies. Jim is also a fervent advocate of PostgreSQL. He is on the board of the United States PostgreSQL Association as well as a part of the organizing teams of the New York PostgreSQL User Group and Philadelphia PostgreSQL User Group. Kirk Roybal has been an active member of the PostgreSQL community since 1998. He has helped organize user groups in Houston, Dallas, and Bloomington, IL. He has mentored many junior database administrators and provided cross-training to senior database engineers. He has provided solutions using PostgreSQL for reporting, business intelligence, data warehousing, applications, and development support. He saw the scope of PostgreSQL when his first small-scale business customer asked for a web application. At that time, competitive database products were either extremely immature or cost prohibitive. Kirk has stood by his choice of PostgreSQL for many years now. His expertise is founded on keeping up with features and capabilities as they become available. Writing a book has been a unique experience for me. Many people fantasize about it, few start one, and even fewer get to publication. I am proud to be part of a team that actually made it to the book shelf (which itself is a diminishing breed). Thanks to Sarah Cullington from Packt Publishing for giving me a chance to participate in the project. I believe that the PostgreSQL
  • 21. community will be better served by this information, and I hope that they receive this as a reward for the time that they have invested in me over the years. A book only has the value that the readers give it. Thank you to the PostgreSQL community for all the technical, personal, and professional development help you have provided. The PostgreSQL community is a great bunch of people, and I have enjoyed the company of many of them. I hope to contribute more to this project in the future, and I hope you find my contributions as valuable as I find yours. Thank you to my family for giving me a reason to succeed and for listening to the gobbledygook and nodding appreciatively. Have you ever had your family ask you what you were doing and answered them with a function? Try it. No, then again, don't try it. They may just have you involuntarily checked in somewhere.
  • 22. About the Reviewers Stephen Frost is a major contributor and committer to PostgreSQL, who has been involved with PostgreSQL since 2002, and has developed features such as the role system and column-level privileges. He is the chief technology officer at Crunchy Data Solutions, Inc., the PostgreSQL company for Secure Enterprises. He is involved in the advancement of PostgreSQL's capabilities, particularly in the area of security in order to support the needs of government and financial institutions who have strict security and regulatory requirements. Rick van Hattem is an entrepreneur with a computer science background and a long-time open source developer with vast experience in the C, C++, Python, and Java languages. Additionally, he has worked with most large database servers such as Oracle, MS SQL, and MySQL, but he has been focusing on PostgreSQL since Version 7.4. He is one of the founders of the Fashiolista.com social network, and until recently, he was the CTO. Here, he used PostgreSQL to scale the feeds for millions of users to show that PostgreSQL can hold up to NoSQL solutions, given some tuning and additional tools. After Fashiolista, he worked as a freelance consultant for several companies, including 2ndQuadrant. He is currently the founder of PGMon.com, a monitoring service that analyzes your databases, indexes, and queries to keep them running at peak performance. In addition to analyzing your database settings, the system actively monitors your queries and gives you recommendations to enhance performance. He is also the creator and maintainer of a large number of open source projects, such as pg_query_analyser, pg_cascade_timestamp,
  • 23. QtQuery, Python-Statsd, and Django-Statsd. Vibhor Kumar is a principal system architect at EnterpriseDB who specializes in assisting Fortune 100 companies to deploy, manage, and optimize Postgres databases. He joined EnterpriseDB in 2008 to work with Postgres after several years of working with Oracle systems. He has worked in team leadership roles at IBM Global Services and BMC Software as well as an Oracle database administrator at CMC Ltd. for several years. He has developed expertise in Oracle, DB2, and MongoDB and holds certifications in them. He has experience working with MS SQL Server, MySQL, and data warehousing. He holds a bachelor's degree in computer science from the University of Lucknow and a master's degree in computer science from the Army Institute of Management, Kolkata. He is a certified PostgreSQL trainer and holds a professional certification in Postgres Plus Advanced Server from EnterpriseDB. Jeff Lawson has been a fan and user of PostgreSQL since the time he discovered it in 2001. Over the years, he has also developed and deployed applications for IBM DB2, Oracle, MySQL, Microsoft SQL Server, Sybase, and others, but he always prefers PostgreSQL for its balance of features and openness. Much of his experience involves developing for Internet-facing websites/projects that require highly scalable databases with high availability or with provisions for disaster recovery. He currently works as the director of software development for FlightAware, which is an airplane-tracking website that uses PostgreSQL and other open source software to store and analyze the positions of the thousands of flights that are operated worldwide every day. He has extensive experience in software architecture, data security, and network protocol design from the software engineering positions he has held at Univa / United Devices, Microsoft, NASA's Jet Propulsion Laboratory, and WolfeTech. He is a founder of distributed.net, which pioneered distributed computing in the 1990s, and he continues to serve as the chief of operations and
  • 24. as a member of the board there. He earned a BSc degree in computer science from Harvey Mudd College. He is fond of cattle, holds an FAA private pilot certificate, and owns an airplane based in Houston, Texas. Mariano Reingart lives in Buenos Aires, Argentina, and is a specialist in the software development of applications and libraries (web services, PDF, GUI, replication, and so on) with more than 10 years of experience. Currently, he is the PostgreSQL regional contact for Argentina and a Python Software Foundation member. He is a major contributor to the web2py Python web framework, and now he's working on the wxWidgets multiplatform GUI toolkit (specifically in the Qt port and Android mobile areas). Also, he has contributed to more than a dozen open source projects, including an interface for Free Electronic Invoice web services (PyAfipWs) and Pythonic replication for PostgreSQL (PyReplica). He has a bachelor's degree in computer systems analysis, and currently, he's a master's candidate for the MSc in free software degree at the Open University of Catalonia. He works on his own funded entrepreneurial venture formed by an open group of independent professionals, dedicated to software development, training, and technical support, focusing on open source tools (GNU/Linux, Python, PostgreSQL, and web2py/wxPython). He has worked for local Python-based companies in large business applications (ERP, SCM, and CRM) and mission critical systems (election counting, electronic voting, and 911 emergency events support). He has contributed to books such as web2py Enterprise Web Framework, Third Edition, and web2py Application Development Cookbook, Packt Publishing, and several Spanish translations of the PostgreSQL official documentation.
  • 25. His full resume is available at http://reingart.blogspot.com/p/resume.html. Julien Tachoires is a PostgreSQL specialist, who works as consultant for the French PostgreSQL company Dalibo. He is the main developer of pg_activity, a top-end software dedicated to follow the PostgreSQL incoming traffic in real time, which is written in Python. I want to thank my employer Dalibo; my wife, Camille; and my son, Arthur.
  • 26. www.PacktPub.com Support files, eBooks, discount offers, and more For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. https://www2.packtpub.com/books/subscription/packtlib Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books. Why subscribe? Fully searchable across every book published by Packt Copy and paste, print, and bookmark content
  • 27. On demand and accessible via a web browser Free access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
  • 28. Preface This fascinating guide to server programming will take your skills of PostgreSQL to a whole new level. A step-by-step approach with illuminating examples will educate you about the full range of possibilities. You will understand the extension framework of PostgreSQL and leverage it in ways you haven't even invented yet. You will learn how to write functions and create your own data types, all in your favorite programming language. It is a step-by-step tutorial, with plenty of tips and tricks to kick-start server programming.
  • 29. What this book covers Chapter 1, What Is a PostgreSQL Server?, introduces you to the PostgreSQL server and will set the tone for the rest of the book. It introduces you to the ways in which a PostgreSQL server is extendible, and shows you that it can be treated as a complete software development framework instead of just a database server. Chapter 2, Server Programming Environments, elaborates that PostgreSQL is built to handle user needs, but more importantly, it is built not to change underneath users in the future. It will touch upon the environments and will highlight some of the important things to be kept in mind when programming on the server in PostgreSQL. Chapter 3, Your First PL/pgSQL Function, builds the foundations by demonstrating how to write simple PL/pgSQL functions. Chapter 4, Returning Structured Data, builds on the knowledge of writing PL/pgSQL functions and demonstrates how to write functions that return a set of values such as rows, arrays, and cursors. Chapter 5, PL/pgSQL Trigger Functions, discusses how to write PL/pgSQL functions that are used to write trigger logic. It also discusses the various types of triggers available in PostgreSQL and the options that a database developer has when writing such functions. Chapter 6, PostgreSQL Event Triggers, discusses PostgreSQL's event trigger functionality. Event triggers are fired when running a DDL operation on a table. This chapter discusses the various possibilities and options of creating event triggers and their limitations in PostgreSQL. Chapter 7, Debugging PL/pgSQL, elaborates on how to debug PL/pgSQL's stored procedures and functions in PostgreSQL. This
  • 30. chapter explains how to install the debugger plugin and use the pgAdmin debugger console. Chapter 8, Using Unrestricted Languages, explains the differences between restricted and unrestricted PostgreSQL languages. This chapter uses PL/Python as an example and demonstrates the examples of both restricted and unrestricted functions in PL/Python. Chapter 9, Writing Advanced Functions in C, explains how to extend PostgreSQL by writing user-defined functions (UDFs) in C. Chapter 10, Scaling Your Database with PL/Proxy, explains the use of a special programming language in PostgreSQL called PL/Proxy and how to use it in order to partition and shard your database. Chapter 11, PL/Perl – Perl Procedural Language, discusses a popular PL language in PostgreSQL called PL/Perl. This chapter uses some simple examples to demonstrate how you can use Perl to write database functions. Chapter 12, PL/Tcl – Tcl Procedural Language, discusses Tcl as a language of choice when writing database functions. It discusses the pros and cons of using Tcl in the database. Chapter 13, Publishing Your Code as PostgreSQL Extensions, discusses how to package and distribute the PostgreSQL extensions. Well-packaged extensions can be easily distributed and installed by other users. This chapter also introduces you to the PostgreSQL Extension Network (PGXN) and shows you how to use it to get the extensions published by other developers. Chapter 14, PostgreSQL as an Extensible RDBMS, discusses more extensibility options in PostgreSQL, such as creating new data types, operators, and index methods.
  • 31. What you need for this book In order to follow this book, you need the following software: PostgreSQL Database Server 9.4 Linux/Unix Operating System Python 2, Perl, and Tcl
  • 32. Who this book is for This book is for moderate to advanced level PostgreSQL database professionals. To get a better understanding of this book, you should have a general experience in writing SQL, a basic idea of query tuning, and some coding experience in a language of your choice.
  • 33. Conventions In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "If any of the checks fail, you should do ROLLBACK instead of COMMIT." A block of code is set as follows: CREATE TABLE accounts(owner text, balance numeric, amount numeric); INSERT INTO accounts VALUES ('Bob',100); INSERT INTO accounts VALUES ('Mary',200); When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold: CREATE OR REPLACE FUNCTION fibonacci_seq(num integer) RETURNS SETOF integer AS $$ DECLARE a int := 0; b int := 1; BEGIN IF (num <= 0) THEN RETURN; END IF;
  • 34. Another Random Scribd Document with Unrelated Content
  • 35. *** END OF THE PROJECT GUTENBERG EBOOK CHRONIQUES DE J. FROISSART, TOME 07/13 *** Updated editions will replace the previous one—the old editions will be renamed. Creating the works from print editions not protected by U.S. copyright law means that no one owns a United States copyright in these works, so the Foundation (and you!) can copy and distribute it in the United States without permission and without paying copyright royalties. Special rules, set forth in the General Terms of Use part of this license, apply to copying and distributing Project Gutenberg™ electronic works to protect the PROJECT GUTENBERG™ concept and trademark. Project Gutenberg is a registered trademark, and may not be used if you charge for an eBook, except by following the terms of the trademark license, including paying royalties for use of the Project Gutenberg trademark. If you do not charge anything for copies of this eBook, complying with the trademark license is very easy. You may use this eBook for nearly any purpose such as creation of derivative works, reports, performances and research. Project Gutenberg eBooks may be modified and printed and given away—you may do practically ANYTHING in the United States with eBooks not protected by U.S. copyright law. Redistribution is subject to the trademark license, especially commercial redistribution. START: FULL LICENSE
  • 36. THE FULL PROJECT GUTENBERG LICENSE PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK To protect the Project Gutenberg™ mission of promoting the free distribution of electronic works, by using or distributing this work (or any other work associated in any way with the phrase “Project Gutenberg”), you agree to comply with all the terms of the Full Project Gutenberg™ License available with this file or online at www.gutenberg.org/license. Section 1. General Terms of Use and Redistributing Project Gutenberg™ electronic works 1.A. By reading or using any part of this Project Gutenberg™ electronic work, you indicate that you have read, understand, agree to and accept all the terms of this license and intellectual property (trademark/copyright) agreement. If you do not agree to abide by all the terms of this agreement, you must cease using and return or destroy all copies of Project Gutenberg™ electronic works in your possession. If you paid a fee for obtaining a copy of or access to a Project Gutenberg™ electronic work and you do not agree to be bound by the terms of this agreement, you may obtain a refund from the person or entity to whom you paid the fee as set forth in paragraph 1.E.8. 1.B. “Project Gutenberg” is a registered trademark. It may only be used on or associated in any way with an electronic work by people who agree to be bound by the terms of this agreement. There are a few things that you can do with most Project Gutenberg™ electronic works even without complying with the full terms of this agreement. See paragraph 1.C below. There are a lot of things you can do with Project Gutenberg™ electronic works if you follow the terms of this agreement and
  • 37. help preserve free future access to Project Gutenberg™ electronic works. See paragraph 1.E below. 1.C. The Project Gutenberg Literary Archive Foundation (“the Foundation” or PGLAF), owns a compilation copyright in the collection of Project Gutenberg™ electronic works. Nearly all the individual works in the collection are in the public domain in the United States. If an individual work is unprotected by copyright law in the United States and you are located in the United States, we do not claim a right to prevent you from copying, distributing, performing, displaying or creating derivative works based on the work as long as all references to Project Gutenberg are removed. Of course, we hope that you will support the Project Gutenberg™ mission of promoting free access to electronic works by freely sharing Project Gutenberg™ works in compliance with the terms of this agreement for keeping the Project Gutenberg™ name associated with the work. You can easily comply with the terms of this agreement by keeping this work in the same format with its attached full Project Gutenberg™ License when you share it without charge with others. 1.D. The copyright laws of the place where you are located also govern what you can do with this work. Copyright laws in most countries are in a constant state of change. If you are outside the United States, check the laws of your country in addition to the terms of this agreement before downloading, copying, displaying, performing, distributing or creating derivative works based on this work or any other Project Gutenberg™ work. The Foundation makes no representations concerning the copyright status of any work in any country other than the United States. 1.E. Unless you have removed all references to Project Gutenberg:
  • 38. 1.E.1. The following sentence, with active links to, or other immediate access to, the full Project Gutenberg™ License must appear prominently whenever any copy of a Project Gutenberg™ work (any work on which the phrase “Project Gutenberg” appears, or with which the phrase “Project Gutenberg” is associated) is accessed, displayed, performed, viewed, copied or distributed: This eBook is for the use of anyone anywhere in the United States and most other parts of the world at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this eBook or online at www.gutenberg.org. If you are not located in the United States, you will have to check the laws of the country where you are located before using this eBook. 1.E.2. If an individual Project Gutenberg™ electronic work is derived from texts not protected by U.S. copyright law (does not contain a notice indicating that it is posted with permission of the copyright holder), the work can be copied and distributed to anyone in the United States without paying any fees or charges. If you are redistributing or providing access to a work with the phrase “Project Gutenberg” associated with or appearing on the work, you must comply either with the requirements of paragraphs 1.E.1 through 1.E.7 or obtain permission for the use of the work and the Project Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9. 1.E.3. If an individual Project Gutenberg™ electronic work is posted with the permission of the copyright holder, your use and distribution must comply with both paragraphs 1.E.1 through 1.E.7 and any additional terms imposed by the copyright holder. Additional terms will be linked to the Project Gutenberg™ License for all works posted with the permission of the copyright holder found at the beginning of this work.
  • 39. 1.E.4. Do not unlink or detach or remove the full Project Gutenberg™ License terms from this work, or any files containing a part of this work or any other work associated with Project Gutenberg™. 1.E.5. Do not copy, display, perform, distribute or redistribute this electronic work, or any part of this electronic work, without prominently displaying the sentence set forth in paragraph 1.E.1 with active links or immediate access to the full terms of the Project Gutenberg™ License. 1.E.6. You may convert to and distribute this work in any binary, compressed, marked up, nonproprietary or proprietary form, including any word processing or hypertext form. However, if you provide access to or distribute copies of a Project Gutenberg™ work in a format other than “Plain Vanilla ASCII” or other format used in the official version posted on the official Project Gutenberg™ website (www.gutenberg.org), you must, at no additional cost, fee or expense to the user, provide a copy, a means of exporting a copy, or a means of obtaining a copy upon request, of the work in its original “Plain Vanilla ASCII” or other form. Any alternate format must include the full Project Gutenberg™ License as specified in paragraph 1.E.1. 1.E.7. Do not charge a fee for access to, viewing, displaying, performing, copying or distributing any Project Gutenberg™ works unless you comply with paragraph 1.E.8 or 1.E.9. 1.E.8. You may charge a reasonable fee for copies of or providing access to or distributing Project Gutenberg™ electronic works provided that: • You pay a royalty fee of 20% of the gross profits you derive from the use of Project Gutenberg™ works calculated using the method you already use to calculate your applicable taxes. The fee is owed to the owner of the Project Gutenberg™ trademark,
  • 40. but he has agreed to donate royalties under this paragraph to the Project Gutenberg Literary Archive Foundation. Royalty payments must be paid within 60 days following each date on which you prepare (or are legally required to prepare) your periodic tax returns. Royalty payments should be clearly marked as such and sent to the Project Gutenberg Literary Archive Foundation at the address specified in Section 4, “Information about donations to the Project Gutenberg Literary Archive Foundation.” • You provide a full refund of any money paid by a user who notifies you in writing (or by e-mail) within 30 days of receipt that s/he does not agree to the terms of the full Project Gutenberg™ License. You must require such a user to return or destroy all copies of the works possessed in a physical medium and discontinue all use of and all access to other copies of Project Gutenberg™ works. • You provide, in accordance with paragraph 1.F.3, a full refund of any money paid for a work or a replacement copy, if a defect in the electronic work is discovered and reported to you within 90 days of receipt of the work. • You comply with all other terms of this agreement for free distribution of Project Gutenberg™ works. 1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™ electronic work or group of works on different terms than are set forth in this agreement, you must obtain permission in writing from the Project Gutenberg Literary Archive Foundation, the manager of the Project Gutenberg™ trademark. Contact the Foundation as set forth in Section 3 below. 1.F.
  • 41. 1.F.1. Project Gutenberg volunteers and employees expend considerable effort to identify, do copyright research on, transcribe and proofread works not protected by U.S. copyright law in creating the Project Gutenberg™ collection. Despite these efforts, Project Gutenberg™ electronic works, and the medium on which they may be stored, may contain “Defects,” such as, but not limited to, incomplete, inaccurate or corrupt data, transcription errors, a copyright or other intellectual property infringement, a defective or damaged disk or other medium, a computer virus, or computer codes that damage or cannot be read by your equipment. 1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for the “Right of Replacement or Refund” described in paragraph 1.F.3, the Project Gutenberg Literary Archive Foundation, the owner of the Project Gutenberg™ trademark, and any other party distributing a Project Gutenberg™ electronic work under this agreement, disclaim all liability to you for damages, costs and expenses, including legal fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE. 1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you discover a defect in this electronic work within 90 days of receiving it, you can receive a refund of the money (if any) you paid for it by sending a written explanation to the person you received the work from. If you received the work on a physical medium, you must return the medium with your written explanation. The person or entity that provided you with the defective work may elect to provide a replacement copy in lieu
  • 42. of a refund. If you received the work electronically, the person or entity providing it to you may choose to give you a second opportunity to receive the work electronically in lieu of a refund. If the second copy is also defective, you may demand a refund in writing without further opportunities to fix the problem. 1.F.4. Except for the limited right of replacement or refund set forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PURPOSE. 1.F.5. Some states do not allow disclaimers of certain implied warranties or the exclusion or limitation of certain types of damages. If any disclaimer or limitation set forth in this agreement violates the law of the state applicable to this agreement, the agreement shall be interpreted to make the maximum disclaimer or limitation permitted by the applicable state law. The invalidity or unenforceability of any provision of this agreement shall not void the remaining provisions. 1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation, the trademark owner, any agent or employee of the Foundation, anyone providing copies of Project Gutenberg™ electronic works in accordance with this agreement, and any volunteers associated with the production, promotion and distribution of Project Gutenberg™ electronic works, harmless from all liability, costs and expenses, including legal fees, that arise directly or indirectly from any of the following which you do or cause to occur: (a) distribution of this or any Project Gutenberg™ work, (b) alteration, modification, or additions or deletions to any Project Gutenberg™ work, and (c) any Defect you cause.
  • 43. Section 2. Information about the Mission of Project Gutenberg™ Project Gutenberg™ is synonymous with the free distribution of electronic works in formats readable by the widest variety of computers including obsolete, old, middle-aged and new computers. It exists because of the efforts of hundreds of volunteers and donations from people in all walks of life. Volunteers and financial support to provide volunteers with the assistance they need are critical to reaching Project Gutenberg™’s goals and ensuring that the Project Gutenberg™ collection will remain freely available for generations to come. In 2001, the Project Gutenberg Literary Archive Foundation was created to provide a secure and permanent future for Project Gutenberg™ and future generations. To learn more about the Project Gutenberg Literary Archive Foundation and how your efforts and donations can help, see Sections 3 and 4 and the Foundation information page at www.gutenberg.org. Section 3. Information about the Project Gutenberg Literary Archive Foundation The Project Gutenberg Literary Archive Foundation is a non- profit 501(c)(3) educational corporation organized under the laws of the state of Mississippi and granted tax exempt status by the Internal Revenue Service. The Foundation’s EIN or federal tax identification number is 64-6221541. Contributions to the Project Gutenberg Literary Archive Foundation are tax deductible to the full extent permitted by U.S. federal laws and your state’s laws. The Foundation’s business office is located at 809 North 1500 West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
  • 44. links and up to date contact information can be found at the Foundation’s website and official page at www.gutenberg.org/contact Section 4. Information about Donations to the Project Gutenberg Literary Archive Foundation Project Gutenberg™ depends upon and cannot survive without widespread public support and donations to carry out its mission of increasing the number of public domain and licensed works that can be freely distributed in machine-readable form accessible by the widest array of equipment including outdated equipment. Many small donations ($1 to $5,000) are particularly important to maintaining tax exempt status with the IRS. The Foundation is committed to complying with the laws regulating charities and charitable donations in all 50 states of the United States. Compliance requirements are not uniform and it takes a considerable effort, much paperwork and many fees to meet and keep up with these requirements. We do not solicit donations in locations where we have not received written confirmation of compliance. To SEND DONATIONS or determine the status of compliance for any particular state visit www.gutenberg.org/donate. While we cannot and do not solicit contributions from states where we have not met the solicitation requirements, we know of no prohibition against accepting unsolicited donations from donors in such states who approach us with offers to donate. International donations are gratefully accepted, but we cannot make any statements concerning tax treatment of donations received from outside the United States. U.S. laws alone swamp our small staff.
  • 45. Please check the Project Gutenberg web pages for current donation methods and addresses. Donations are accepted in a number of other ways including checks, online payments and credit card donations. To donate, please visit: www.gutenberg.org/donate. Section 5. General Information About Project Gutenberg™ electronic works Professor Michael S. Hart was the originator of the Project Gutenberg™ concept of a library of electronic works that could be freely shared with anyone. For forty years, he produced and distributed Project Gutenberg™ eBooks with only a loose network of volunteer support. Project Gutenberg™ eBooks are often created from several printed editions, all of which are confirmed as not protected by copyright in the U.S. unless a copyright notice is included. Thus, we do not necessarily keep eBooks in compliance with any particular paper edition. Most people start at our website which has the main PG search facility: www.gutenberg.org. This website includes information about Project Gutenberg™, including how to make donations to the Project Gutenberg Literary Archive Foundation, how to help produce our new eBooks, and how to subscribe to our email newsletter to hear about new eBooks.
  • 46. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! textbookfull.com