0% found this document useful (0 votes)
4 views52 pages

PostgreSQL Server Programming 2nd Edition Usama Dar download

The document provides information about the book 'PostgreSQL Server Programming, 2nd Edition' by Usama Dar, including details such as authors, ISBN, and a download link. It outlines the book's content, which covers various aspects of PostgreSQL server programming, including PL/pgSQL functions, triggers, debugging, and advanced functions in C. Additionally, it mentions other related products available for download on the same website.

Uploaded by

zjtnjxw1006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views52 pages

PostgreSQL Server Programming 2nd Edition Usama Dar download

The document provides information about the book 'PostgreSQL Server Programming, 2nd Edition' by Usama Dar, including details such as authors, ISBN, and a download link. It outlines the book's content, which covers various aspects of PostgreSQL server programming, including PL/pgSQL functions, triggers, debugging, and advanced functions in C. Additionally, it mentions other related products available for download on the same website.

Uploaded by

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

PostgreSQL Server Programming 2nd Edition Usama Dar

download pdf

https://ebookultra.com/download/postgresql-server-programming-2nd-
edition-usama-dar/

Visit ebookultra.com today to download the complete set of


ebook or textbook!
Here are some recommended products for you. Click the link to
download, or explore more at ebookultra.com

PostgreSQL 2nd Edition Korry Douglas

https://ebookultra.com/download/postgresql-2nd-edition-korry-douglas/

Professional SQL Server 2005 Programming Robert Vieira

https://ebookultra.com/download/professional-sql-
server-2005-programming-robert-vieira/

Beginning Databases with PostgreSQL From Novice to


Professional 2nd Edition Matthew

https://ebookultra.com/download/beginning-databases-with-postgresql-
from-novice-to-professional-2nd-edition-matthew/

PostgreSQL Cookbook 1st Edition Chitij Chauhan

https://ebookultra.com/download/postgresql-cookbook-1st-edition-
chitij-chauhan/
Learning PostgreSQL Create develop and manage relational
databases in real world applications using PostgreSQL 1st
Edition Juba
https://ebookultra.com/download/learning-postgresql-create-develop-
and-manage-relational-databases-in-real-world-applications-using-
postgresql-1st-edition-juba/

Programming Microsoft SQL Server 2000 with Microsoft


Visual Basic NET 1st edition Edition Rick Dobson

https://ebookultra.com/download/programming-microsoft-sql-
server-2000-with-microsoft-visual-basic-net-1st-edition-edition-rick-
dobson/

Building Bluetooth Low Energy Systems 1st Edition Muhammad


Usama Bin Aftab

https://ebookultra.com/download/building-bluetooth-low-energy-
systems-1st-edition-muhammad-usama-bin-aftab/

Computer Networks An Open Source Approach 1st Edition


Ying-Dar Lin

https://ebookultra.com/download/computer-networks-an-open-source-
approach-1st-edition-ying-dar-lin/

Server study guide 2nd ed Edition Brad Hryhoruk

https://ebookultra.com/download/server-study-guide-2nd-ed-edition-
brad-hryhoruk/
PostgreSQL Server Programming 2nd Edition Usama
Dar Digital Instant Download
Author(s): Usama Dar, Hannu Krosing, Jim Mlodgenski, Kirk Roybal
ISBN(s): 9781783980581, 1783980583
Edition: 2
File Details: PDF, 2.28 MB
Year: 2015
Language: english
PostgreSQL Server Programming Second
Edition
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
Random documents with unrelated
content Scribd suggests to you:
"There's a bullet in there," he said proudly. "I'm going to have it cut
out, and then go right back to the fight. Isn't it lucky it's my left
hand?"

As the day wore on I became more and more absorbed in my


work. I had, too, the stimulus of a reproof from Miss Deborah
Couch, a brisk, efficient middle-aged lady, who asked no quarter and
gave none. She was standing beside me a moment, with a bright tin
pan filled with pure water, into which I foolishly dipped a finger to
see if it were warm; to learn if I would be expected to provide warm
water when I should be called upon to assist the surgeon.

"This water, Madam, was prepared for a raw wound," said Miss
Deborah, sternly. "I must now make the surgeon wait until I get
more."

Miss Deborah, in advance of her time, was a germ theorist. My


touch evidently was contaminating.

As she charged down the aisle with a pan of water in her hand,
everybody made way. She had known of my "fine-lady faintness," as
she termed it, and I could see she despised me for it. She had
volunteered, as all the nurses had, and she meant business. She had
no patience with nonsense, and truly she was worth more than all
the rest of us.

"Where can I get a little ice?" I one day ventured of Miss


Deborah.

"Find it," she rejoined, as she rapidly passed on; but find it I
never did. Ice was an unknown luxury until brought to us later from
private houses.

But I found myself thoroughly reinstated—with surgeons,


matron, and Miss Deborah—when I appeared a few days later,
accompanied by a man bearing a basket of clean, well-rolled
bandages, with promise of more to come. The Petersburg women
had gone to work with a will upon my table-cloths, sheets, and
dimity counterpanes—and even the chintz furniture covers. My
springlike green and white chintz bandages appeared on many a
manly arm and leg. My fine linen underwear and napkins were cut,
by the sewing circle at the Spotswood, according to the surgeon's
directions, into lengths two inches wide, then folded two inches,
doubling back and forth in a smaller fold each time, until they
formed pointed wedges for compresses.

Such was the sudden and overwhelming demand for such


things, that but for my own and similar donations of household
linen, the wounded men would have suffered. The war had come
upon us suddenly. Many of our ports were already closed, and we
had no stores laid up for such an emergency.

The bloody battle of Gaines's Mill soon followed—then Frazier's


Farm, within the week, and at once the hospital was filled to
overflowing. Every night a courier brought me tidings of my
husband. When I saw him at the door my heart would die within
me! One morning John came in for certain supplies. After being
reassured as to his master's safety, I asked, "Did he have a
comfortable night, John?"

"He sholy did! Marse Roger cert'nly was comfortable las' night.
He slep' on de field 'twixt two daid horses!"

The women who worked in Kent & Paine's hospital never


seemed to weary. After a while the wise matron assigned us hours,
and we went on duty with the regularity of trained nurses. My hours
were from seven to seven during the day, with the promise of night
service should I be needed. Efficient, kindly colored women assisted
us. Their motherly manner soothed the prostrate soldier, whom they
always addressed as "son."
Many fine young fellows lost their lives for want of prompt
attention. They never murmured. They would give way to those who
seemed to be more seriously wounded than themselves, and the
latter would recover, while from the slighter wounds gangrene would
supervene from delay. Very few men ever walked away from that
hospital. They died, or friends found quarters for them in the homes
in Richmond. None complained! Unless a poor man grew delirious,
he never groaned. There was an atmosphere of gentle kindness, a
suppression of emotion for the sake of others.

Every morning the Richmond ladies brought for our patients


such luxuries as could be procured in that scarce time. The city was
in peril, and distant farmers feared to bring in their fruits and
vegetables. One day a patient-looking middle-aged man said to me,
"What would I not give for a bowl of chicken broth like that my
mother used to give me when I was a sick boy!" I perceived one of
the angelic matrons of Richmond at a distance, stooping over the
cots, and found my way to her and said: "Dear Mrs. Maben, have
you a chicken? And could you send some broth to No. 39?" She
promised, and I returned with her promise to the poor wounded
fellow. He shook his head. "To-morrow will be too late," he said.

I had forgotten the circumstance next day, but at noon I


happened to look toward cot No. 39, and there was Mrs. Maben
herself. She had brought the chicken broth in a pretty china bowl,
with napkin and silver spoon, and was feeding my doubting Thomas,
to his great satisfaction.

It was at this hospital, I have reason to believe, that the little


story originated, which was deemed good enough to be claimed by
other hospitals, of the young girl who approached a sick man with a
pan of water in her hand and a towel over her arm.

"Mayn't I wash your face?" said the girl, timidly.


"Well, lady, you may if you want to," said the man, wearily. "It
has been washed fourteen times this morning! It can stand another
time, I reckon."

I discovered that I had not succeeded, despite many efforts, in


winning Miss Deborah. I learned that she was affronted because I
had not shared my offerings of jelly and fruit with her, for her special
patients. Whenever I ventured to ask a loan from her, of a pan or a
glass for water or the little things of which we never had enough,
she would reply, "I must keep them for the nurses who understand
reciprocity. Reciprocity is a rule some persons never seem to
comprehend." When this was hammered into my slow perception, I
rose to the occasion. I turned over the entire contents of a basket
the landlord of the Spotswood had given me to Miss Deborah, and
she made my path straight before me ever afterward.

At the end of a week the matron had promoted me! Instead of


carving the fat bacon, to be dispensed with corn bread, for the
hospital dinner, or standing between two rough men to keep away
the flies, or fetching water, or spreading sheets on cots, I was
assigned to regular duty with one patient.

The first of these proved to be young Colonel Coppens, of my


husband's brigade. I could comfort him very little, for he was
wounded past recovery. I spoke little French, and could only try to
keep him, as far as possible, from annoyance. To my great relief,
place was found for him in a private family. There he soon died—the
gallant fellow I had admired on his horse a few months before.

Then I was placed beside the cot of Mr. (or Captain) Boyd of
Mecklenburg, and was admonished by the matron not to leave him
alone. He was the most patient sufferer in the world, gentle,
courteous, always considerate, never complaining. I observed he
often closed his eyes and sighed. "Are you in pain, Captain?" "No,
no," he would say gently. One day, when I returned from my "rest,"
I found the matron sitting beside him. Tears were running down her
cheeks. She motioned me to take her place, and then added, "No,
no, I will not leave him."

The Captain's eyes were closed, and he sighed wearily at


intervals. Presently he whispered slowly:—

"There everlasting spring abides,"

then sighed, and seemed to sleep for a moment.

The matron felt his pulse and raised a warning hand. The sick
man's whisper went on:—

"Bright fields beyond the swelling flood


Stand—dressed—in living green."

The surgeon stood at the foot of the cot and shook his head.
The nurses gathered around with tearful eyes. Presently in clear
tones:—

"Not Jordan's stream—nor death's cold flood


Shall fright us—from—the shore,"

and in a moment more the Christian soldier had crossed the river
and lain down to rest under the trees.

Each of the battles of those seven days brought a harvest of


wounded to our hospital. I used to veil myself closely as I walked to
and from my hotel, that I might shut out the dreadful sights in the
street,—the squads of prisoners, and, worst of all, the open wagons
in which the dead were piled. Once I did see one of these dreadful
wagons! In it a stiff arm was raised, and shook as it was driven
down the street, as though the dead owner appealed to Heaven for
vengeance; a horrible sight never to be forgotten.

After one of the bloody battles—I know not if it was Gaines's Mill
or Frazier's Farm or Malvern Hill—a splendid young officer, Colonel
Brokenborough, was taken to our hospital, shot almost to pieces. He
was borne up the stairs and placed in a cot—his broken limbs in
supports swinging from the ceiling. The wife of General Mahone and
I were permitted to assist in nursing him. A young soldier from the
camp was detailed to help us, and a clergyman was in constant
attendance, coming at night that we might rest. Our patient held a
court in his corner of the hospital. Such a dear, gallant, cheery
fellow, handsome, and with a grand air even as he lay prostrate!
Nobody ever heard him complain. He would welcome us in the
morning with the brightest smile. His aide said, "He watches the
head of the stairs and calls up that look for your benefit." "Oh," he
said one day, "you can't guess what's going to happen! Some ladies
have been here and left all these roses, and cologne, and such; and
somebody has sent—champagne! We are going to have a party!"

Ah, but we knew he was very ill! We were bidden to watch him
every minute and not be deceived by his own spirits. Mrs. Mahone
spent her life hunting for ice. My constant care was to keep his
canteen—to which he clung with affection—filled with fresh water
from a spring not far away, and I learned to give it to him so well
that I allowed no one to lift his head for his drink during my hours.

One day, when we were alone, I was fanning him, and thought
he was asleep. He said gravely, "Mrs. Pryor, beyond that curtain they
hung up yesterday poor young Mitchell is lying! They think I don't
know! But I heard when they brought him in,—as I lie here, I listen
to his breathing. I haven't heard it now for some time. Would you
mind seeing if he is all right?"
I passed behind the curtain. The young soldier was dead. His
wide-open eyes seemed to meet mine in mute appeal. I had never
seen or touched a dead man, but I laid my hands upon his eyelids
and closed them. I was standing thus when his nurse, a young
volunteer like myself, came to me.

"I couldn't do that," she said; "I went for the doctor. I'm so glad
you could do it."

When I returned Colonel Brokenborough asked no questions and


I knew that his keen senses had already instructed him.

To be cheerful and uncomplaining was the unwritten law of our


hospital. No bad news was ever mentioned, no foreboding or
anxiety. Mrs. Mahone was one day standing beside Colonel
Brokenborough when a messenger from the front suddenly
announced that General Mahone had received a flesh-wound.
Commanding herself instantly, she exclaimed merrily: "Flesh-wound!
Now you all know that is just impossible." The General had no flesh!
He was as thin and attenuated as he was brave.
MALVERN HILL.

As Colonel Brokenborough grew weaker I felt self-reproach that


no one had offered to write letters for him. His friend the clergyman
had said to me: "That poor boy is engaged to a lovely young girl. I
wonder what is best? Would it grieve him to speak of her? You ladies
have so much tact; you might bear it in mind. An opportunity might
offer for you to discover how he feels about it." The next time I was
alone with him I ventured: "Now, Colonel, one mustn't forget absent
friends, you know, even if fair ladies do bring perfumes and roses
and what not. I have some ink and paper here. Shall I write a letter
for you? Tell me what to say."

He turned his head and with a half-amused smile of perfect


intelligence looked at me for a long time. Then an upward look of
infinite tenderness; but the message was never sent—never needed
from a true heart like his.
One night I was awakened from my first sleep by a knock at my
door, and a summons to "come to Colonel Brokenborough." When I
reached his bedside I found the surgeon, the clergyman, and the
Colonel's aide. The patient was unconscious; the end was near. We
sat in silence. Once, when he stirred, I slipped my hand under his
head, and put his canteen once more to his lips. After a long time
his breathing simply ceased, with no evidence of pain. We waited
awhile, and then the young soldier who had been detailed to nurse
him rose, crossed the room, and, stooping over, kissed me on my
forehead, and went out to his duty in the ranks.

Two weeks later I was in my room, resting after a hard day,


when a haggard officer, covered with mud and dust, entered. It was
my husband.

"My men are all dead," he said, with anguish, and, falling across
the bed, he gave vent to the passionate grief of his heart.

Thousands of Confederate soldiers were killed, thousands


wounded.

Richmond was saved!

General McClellan and General Lee both realized that their men
needed rest. My husband was allowed a few days' respite from duty.
Almost without pause he had fought the battles of Williamsburg,
Seven Pines, Mechanicsville, Gaines's Mill, and Frazier's Farm. He
had won his promotion early, but he had lost the loved commander
who appreciated him, had seen old schoolmates and friends fall by
his side,—the dear fellow, George Loyal Gordon, who had been his
best man at our wedding,—old college comrades, valued old
neighbors.

Opposed to him in battle, then and after, were men who in after
years avowed themselves his warm friends,—General Hancock,
General Slocum, General Butterfield, General Sickles, General Fitz-
John Porter, General McClellan, and General Grant. They had fought
loyally under opposing banners, and from time to time, as the war
went on, one and another had been defeated; but over all, and
through all, their allegiance had been given to a banner that has
never surrendered,—the standard of the universal brotherhood of all
true men.
CHAPTER XIV
THE WINTER OF 1861

The privilege of nursing in the hospital had been bought at a


dear price, for it was decided positively that I was to surrender, for
the present, my dream of following the army. I was remanded to the
mountains, and at Charlottesville I had news of the events that
rapidly followed the Seven Days' Battles around Richmond.

McClellan had been relieved of his command, and the


defenceless women and children of Northern Virginia were handed
over to the tender mercies of General Pope. McClellan wrote, August
8: "I will strike square in the teeth of all the infamous orders of Mr.
John Pope, and forbid all pillaging and stealing, and take the highest
Christian ground for the conduct of the war. I will not permit this
army to degenerate into a mob of thieves, nor will I return these
men of mine to their families as a set of wicked and demoralized
robbers."

General Pope had announced his purpose (which he carried out)


to subsist his army on our country, and to hang or shoot any non-
combating citizens who might fall into his hands, in retaliation for
the killing of his soldiers. This was one of "the infamous orders of Mr.
John Pope" to which General McClellan alluded; but infamy to some
eyes is fame to others. Pope superseded McClellan; but he was
himself superseded after his defeat at the hands of Lee, and
McClellan reinstated.

My husband's brigade followed General Lee, fought the battle of


Manassas, where he captured and paroled the hospital corps, went
with him throughout the campaign, into Maryland and back, fought
the battle of South Mountain and the bloody battle of Antietam (or
Sharpsburg).

The histories of these battles have been given again and again
by the military commanders who conducted them. At the close of
the campaign General Lee reported that his men were in the finest
possible condition—only there were too few of them. As the Federal
armies were depleted, they could be reënforced by foreigners. As
our men were lost, we had no fresh troops to take their places.

My husband commanded Anderson's division at Antietam,


General Anderson having been wounded. This battle is quoted, along
with the battle of Seven Pines, as one of the most hotly contested of
the war. Sorely pressed at one time, General Pryor despatched an
orderly to General Longstreet with a request for artillery. The latter
tore the margin from a newspaper and wrote: "I am sending you the
guns, dear General. This is a hard fight and we had better all die
than lose it." At one time during the battle the combatants agreed
upon a brief cessation, that the dead and wounded of both sides
might be removed. While General Pryor waited, a Federal officer
approached him.

"General," said he, "I have just detected one of my men in


robbing the body of one of your soldiers. I have taken his booty
from him, and now consign it to you."

Without examining the small bundle,—tied in a handkerchief,—


my husband ordered it to be properly enclosed and sent to me. The
handkerchief contained a gold watch, a pair of gold sleeve-links, a
few pieces of silver, and a strip of paper on which was written,
"Strike till the last armed foe expires," and signed "A Florida patriot."
There seemed to be no clew by which I might hope to find an
inheritor for these treasures. I could only take care of them.

I brought them forth one day to interest an aged relative, whose


chair was placed in a sunny window. "I think, my dear," she said,
"there are pin-scratched letters on the inside of these sleeve-
buttons." Sure enough, there were three initials, rudely made, but
perfectly plain.

Long afterward I met a Confederate officer from Florida who had


fought at Antietam.

"Did you know any one from your state, Captain, who was killed
at Sharpsburg?"

"Alas! yes," he replied, and mentioned a name corresponding


exactly with the scratched initials.

The parcel, with a letter from me, was sent to an address he


gave me, and in due time I received a most touching letter of thanks
from the mother of the dead soldier.

General Lee went into winter quarters at Culpeper, and thither I


repaired to visit a kind and hospitable family, who were good enough
to invite me. In their home I spent two weeks. I had not imagined
there were so many soldiers in the world as I saw then. "You cannot
take a step anywhere," said a lady, "without treading on a soldier!"
They were in the finest spirits, notwithstanding their long marches
and short rations. Thousands on thousands of Federal troops were in
Virginia. The highways of our chief rivers were closed, our railroads
menaced. Everything we needed was already scarce and held at
high prices. Nobody had comforts or luxuries; nobody murmured
because of such privations.
We made our host's drawing-room a camping ground, his fire
our camp-fire. Around it gathered a nightly crowd of gay young
soldiers. They wished no serious talk, these young warriors! They
had a brief respite from fatigue and sorrow, and they intended to
enjoy it. They sentimentalized, however, over the tender and
mournful song, "Lorena," which even then touched a chord in every
heart, and which meant so much of devotion and heartbreak two
years later. For four years the daughters of the South waited for
their lovers, and some, alas! waited forever.

"It matters little now, Lorena,


The past is the eternal past,
Our heads will soon lie low, Lorena,
Life's tide is ebbing out so fast;
But there's a future—oh! thank God—
Of life this is so small a part;
'Tis dust to dust beneath the sod,
But there, up there,—'tis heart to heart."

With pretty Nelly at the piano, her blue eyes raised to heaven,
and Jack Fleming accompanying her on her guitar, his dark eyes
raised to Nelly, the effect was overwhelming; and lest somebody
should quite finish us by singing, "Flee as a bird to the mountain,"
we would hasten to demand the "Bonnie Blue Flag," or "Dixie," or
the polite invitation to "Joe Hooker" to "come out the Wilderness,"
or, better still, a good story. The latter call would bring many we had
heard before—there are so few good stories in the world—but we
would welcome each one with applause, even if it were no better
than the story of Captain —— (I can't remember the captain's name)
and his black boy "Cæsar." I can only vouch for the story, which ran
thus:—
The captain, going into a skirmish one day, left his tent and its
contents in the care of the boy. "Mayn't I go he'p de cook?" said
Cæsar, much desiring to place himself farther in the rear.

"Stay here, sir, and protect my property!" sternly commanded his


master.

Cæsar, when left alone, grew unhappy, and when straggling shot
fell like hail around the tent, he incontinently fled and hid in the
bushes. When he returned, he found an angry captain indeed.

"You rascal! Didn't I leave you here to protect my property? It


might have been all stolen."

"I knows it, sah, I knows it! An' I did purtect yo' property, sah! I
sholy did! Dem ole cloes ain' wuth nothin'! I'se feared to bresh 'em
less'n I git a hole in 'em; but dis property," laying his hand proudly
on his breast, "dis property is wuth fifteen hundred dollars!"

Of course so good a story was soon capped by another. One of


the boys who had been with my General at Williamsburg could tell it.
A shell had entered the domain of pots and kettles and created what
Domingo the cook termed a "clatteration." He at once started for the
rear.

"What's de matter, Mingo?" asked a fellow-servant, "whar you


gwine wid such a hurrification?"

"I gwine to git out o' trouble—dar whar I gwine. Dar's too much
powder in dem big things. Dis chile ain't gwine bu'n hisself! An' dar's
dem Minnie bullets, too, comin' frew de a'r, singin': 'Whar—is—you?
Whar—is—you?' I ain't gwine stop an' tell 'em whar I is! I'se a
twenty-two-hundurd-dollar nigger, an' I'se gwine tek keer o' what
b'longs to marster, I is."
Of course we heard again the story of Stonewall Jackson's body-
servant, who always knew before anybody when a battle was
imminent.

"The General tells you, I suppose," said one of the soldiers.

"Lawd, no, sir! De Gin'ral nuvver tell me nothin'! I observates de


'tention of de Gin'ral dis way: co'se he prays, jest like we all, mornin'
an' night; but when he gits up two, three times in a night to pray,
den I rubs my eye and gits up too, an' packs de haversack,—ca'se I
done fine out dere's gwine to be de ole boy to pay right away."

Amusing as were the negro stories, there were plenty of others,


revealing the peculiar characteristics of the common soldier. The
soldier from rural districts was a trial to his officers in the early days
of the war. Nothing could make him hurry. "If he came to a stream,
he would deliberately look around for two fence-rails and put them
across, and the time consumed by a company in crossing in this way
can be imagined. If his feet hurt him, he would sit down on the
roadside to tie rags around them." He never could be made to
understand that freedom of speech with an officer, who had been
perhaps a neighbor, was denied him; nor yet that he could not
indulge in good-natured chaff or criticism.

"Are you sentinel here?" asked an officer, who found a sentry


sitting down and cleaning his gun, having taken it entirely to pieces.

"Well, I am a sort of sentinel, I reckon."

"Well, I am a sort of officer of the day."

"Is that so? Just hold on till I get my gun together, and I will
give you a sort of a salute."[16]

When a picket guard at Harper's Ferry was being detailed for


duty, one of these verdant volunteers loudly protested against that
manner of carrying on war.

"What's the use of gwine out thar to keep everybody off?" he


shouted. "We've all kem here to hev a fight with them Yankees, an'
ef you sen' fellers out thar to skeer 'em off, how in thunder are we
gwine to hev a scrimmage?"

In the hardest times of starvation and weariness, according to


our soldier boys, the situation would be relieved by the drollery of
some good-natured, great-hearted countryman. Officers who had an
easy place, and musicians, for a similar reason, were their special
targets. Rather than be tormented, musicians would often leave the
line of march and go through fields to avoid the running fire. "Ah,
now! give us a toot on yer old funnel," or, "Brace up thar with yer
blowpipe!"

These fellows who didn't fight were all classed under the general
term of "bomb-proofs." One of these officers—a little man—having
appeared in an enormous pair of cavalry boots, ran the gantlet of a
neighboring brigade and heard a frank opinion of himself:—

"I say, Mister, better git out'r them smokestacks! We know you're
in thar 'cause we all kin see yer head stickin' out. You needn' say yer
ain't in thar,—'cause yer ears is workin' powerful."
The allusion to the celebrated long-eared animal was awful!

If a "bomb-proof" officer—a fellow who had a position in the


rear—should happen to be smartly dressed when cantering along
near a regiment, he would be apt to change his canter to a gallop as
the men would shout and whoop:—

"Oh, my! Ain't he pooty? Say, Mister! whar'd ye git that biled
shut? Was ye ra-a-ly born so, or was ye put together by corntrack?
Sich a nice-lookin' rooster oughter git down an' scratch for a
wurrum!"
Even when a brigade would pass at double-quick, going into a
battle in which the waiting soldier expected any moment to take
part, the latter would call out:—

"What's your hurry, boys? Gwine to ketch a train?"

They made great fun, too, of their own fears, never considering
them worthy of being treated seriously, or as in any way detrimental.

Under fire at Manassas, a raw recruit was doing pretty well,


when a rabbit loped across the field. Dropping his gun as he was
about to shoot, he yelled, with honest pathos:—

"Go it, little cotton-tail, go it! I'm jest as skeered as you be, an'
ef I dar'd, I'd run too."

A number of militia having given way under fire, their


commanding officer called out to one of the fugitives:—

"What are you running away for, you —— —— coward? You


ought to be ashamed of yourself."

"I ain't runnin' away, Gin'ral! I'm just skeered! Them fellers over
thar are shootin' bullets as big as watermillions! One of 'em went
right peerst my head—right peerst;—an'—an' I wants to go home."

"Well, why didn't you shoot back, sir? You are crying like a
baby."

"I knows it, Gin'ral—I knows it. I wish I was a baby, and a gal-
baby, too, and then I wouldn't hev been cornscripted."

The regiments of Georgia, North Carolina, and Virginia could


never pass each other without some chaffing challenge.

"Hello, North Car'lina," said an officer to a lanky specimen in a


shabby uniform.
"Hello, Virginia."

"Blockade on turpentine making? You all hard up? No sale for tar
now?"

"Well—yes!" was the slow rejoinder. "We sell all our tar to Jeff
Davis now."

"The thunder you do! What does the President want with your
tar?"

"He puts it on the heels of Virginians to make 'em stick to the


battle-field."

The staff officer rode on.

A good story had found its way into our lines from a Federal
officer. He was commenting upon the fact that all Southern women
were intense rebels—with one exception. He had been with others
marching down a wooded lane which ended in a sharp curve. As
they rounded it, they suddenly came upon a house, before which
was a woman picking up chips. As she had evidently not seen them,
the officer tiptoed up to her, put his arm around her waist, and
kissed her—and stepped back to avoid the box on the ear he knew
he deserved. The woman, however, straightened herself, looked at
him seriously for a moment, and said slowly, "You'll find me right
here every mornin' a-pickin' up chips."

It would seem that the telling of stories of a mildly humorous


nature, with the characteristic of dialect, was a feature of the war-
time,—the President of the United States affording a notable
example. When the gravest matters were under consideration, all
things were held in abeyance until the illustrative anecdote was duly
presented. How Mr. Seward chafed under them we all know. The
poor little stories that went the rounds among the rank and file at
the camp-fires in Virginia had their uses. Whatever the weariness,
the discouragement, the failure of the wagons to come up with
provisions, by such simple means did the brave boys lighten their
own and each others' hearts. Whenever they had cards they played;
but before going into battle the camp-ground would be strewn with
them, the soldier of the rank and file always emptying his pockets of
his cards! His Testament was pocketed in their stead.

In repeating these stories around our blazing log fire, and in


describing their marches and hard times, the brave fellows made
sport of all their discomforts and of their shifts to supplement
deficiencies. They told with merriment of the times they had proudly
drawn over their bruised feet boots found on the march, and had
suffered such agony from the swelling of the compressed members
that they were fain to implore a comrade to cut off the instrument of
torture; of the time Mr. Giddings and his pretty daughters
entertained them in Maryland, and of their dreadful embarrassment
at finding they had ravenously swept the table of every biscuit, every
bit of ham, every raw tomato—and had wanted, oh, so much more!
And how some of them had been captured and soon released; but
while prisoners and waiting for a train, how a Federal officer had
talked most kindly to them, inquiring for old West Point comrades of
his who were on our side; and how they on their part had asked
after the welfare of Captain John Lea of Petersburg, who had been
captured at Williamsburg,—to be told by this Federal officer that
Captain Lea had been dreadfully wounded, and while in the hospital
had been nursed by a young lady with whom he fell in love, and that
the officer had been present at their marriage in Williamsburg, and
through his intercession and that of other old West Point comrades
Captain Lea had been released. When the time came for parting with
the courteous officer our boys had respectfully requested his name.
"My name is Custer," he said. "I do not belong to any regiment, but
am on the staff of General McClellan." He was none other than the
famous George A. Custer of the United States cavalry, destined to
win for himself immortal renown, and to meet gallantly an early
death in the fight with the Indians on the Little Big Horn River.

Many of these soldier boys—"boys" now no longer, but


"veterans"—were from Petersburg, and had stood in line on the day
when Alice and Tabb and Marian and Molly and all the other girls
had waited with me to see them off. It was delightful to meet them
and to hear news of the others. Where was Will Johnson? Where
was Berry Stainback? Will had been captured "for no reason
whatever except that he and Berry had but one blanket between
them, and Will had to get himself captured when he found Berry had
been, in order to continue to share the blanket, which was in Berry's
possession," a story which Will's friends could safely invent for their
amusement, as his known courage was beyond all doubt.

General "Jeb" Stuart was a great hero with these soldier boys,
dashing as he did all over the country with his eight thousand
mounted men. He was our plumed knight—with his gold star and
long feather. They never wearied of stories of his promptness, his
celerity, his meteorlike dashes.

"They'll never catch him!" said one proudly. "They'll always reach
the place where he recently was."

"He reminds me of the knights of the olden time," said a young


lady.

"The mediæval knight, my dear young lady," said General


Johnson, "would be of little use in this war. He would have stood no
chance with one of Stuart's men."

"Fancy him," said another, "with his two hundred weight of iron
on him, and as much on his big cart-horse. Imagine him, armed with
a maul or a lance, a battle-axe, and six-foot pole, going into a fight
at Manassas or Antietam."
"He would never get there," said the General. "A light
cavalryman of the First Virginia would have ridden around King
Arthur or Sir Launcelot half a dozen times while the knight was
bracing himself up for action; and the Chicopee sabre would have
searched out the joints under his chin, or his arm, or his sword-belt,
and would have shucked him like an oyster before he could get his
lance in rest."

And Jackson was another of their idols. Stories of his strategy,


his courage, his faith in God, his successes, filled many an hour
around the camp-fire in the hospitable Culpeper mansion.

But the chief idol of their hearts—of all our hearts—was our
beloved commander, our Bayard sans peur et sans reproche, General
Lee. The hand instinctively sought the cap at the mention of his
name. Indignant comments were made upon the newspaper
criticisms of his early misfortunes in the western part of Virginia in
the autumn of 1861, and one occasion was remembered when, his
own attention having been directed to a fierce newspaper attack, as
unjust in its conclusions as it was untrue in its statements, he was
asked why he silently suffered such unwarranted aspersions; and he
had calmly replied that, while it was very hard to bear, it was
perhaps quite natural that such hasty conclusions should be
announced, and that it was better not to attempt a justification or
defence, but to go steadily on in the discharge of duty to the best of
our ability, leaving all else to the calmer judgment of the future and
to a kind Providence.

Happy was the private soldier who had seen General Lee, thrice
happy the one who had spoken to him. Of the latter, a plain
countryman, having listened to the personal incidents of his fellows,
as they related various occasions when they had been noticed by
General Lee, was fired by a desire to emulate them, and confided
that he, too, had once enjoyed a very interesting and gratifying
interview with General Lee. Importuned to tell it, the soldier
modestly hesitated, but urged by an evident incredulity on the part
of his hearers, he took heart of grace and related as follows:—

"I was jest out of the horspittle an' was natchelly strollin' round
when the scrimmage was goin' on, and I saw Gen'ral Lee on a little
rise not fur off. I santered closer an' closer to him, and when I saw
him look at me I says, 'Pretty warm work over thar, Gen'ral.' He give
me a keen look, an' says he, quiet-like: 'Where do you belong?
Where's your regiment?' An' I says, 'I'm lookin' for my regiment now
—Twelfth Virginia.' 'I can help you,' says he; 'there is your regiment
just going into the fight. Hurry up an' join it.' An' I run off proud as a
pigeon."

"Didn't you think you might get shot?" asked his comrade.

"I suttenly did! I always thinks that. But then, thinks I, Gen'ral
Lee will be mighty sorry 'cause he knowed he sent me into danger
when I was feelin' mighty weak an' poly."

The incidents were many which the officers and soldiers could
remember, illustrating the dear commander's peculiar traits. His aide,
Colonel Taylor, has written me of one most touching incident:—

"Tidings reached General Lee, soon after his return to Virginia,


of the serious illness of one of his daughters—the darling of his
flock. For several days apprehensions were entertained that the next
intelligence would be of her death. One morning the mail was
received, and the private letters were distributed as was the custom;
but no one knew whether any home news had been received by the
General. At the usual hour he summoned me to his presence, to
know if there were any matters of army routine upon which his
judgment and action were desired. The papers containing a few
such cases were presented to him; he reviewed, and gave his orders
in regard to them. I then left him, but for some cause returned in a
few moments, and with my accustomed freedom entered his tent
without announcement or ceremony, when I was startled and
shocked to see him overcome with grief, an open letter in his hand.
That letter contained the sad intelligence of his daughter's death.

"Scarcely less to be admired than his sublime devotion to duty,"


continued Colonel Taylor, "was his remarkable self-control. General
Lee was naturally of a positive temperament, and of strong passions;
and it is a mistake to suppose him otherwise; but he held these in
complete subjection to his will and conscience. He was not one of
those invariably amiable men, whose temper is never ruffled; but
when we consider the immense burden which rested upon him, and
the numberless causes for annoyance with which he had to contend,
the occasional cropping out of temper which we, who were
constantly near him, witnessed, only showed how great was his
habitual self-command.

"He had a great dislike to reviewing army communications; this


was so thoroughly appreciated by me that I would never present a
paper for his action unless it was of decided importance, and of a
nature to demand his judgment and decision. On one occasion,
when an audience had not been asked of him for several days, it
became necessary to have one. The few papers requiring his action
were submitted. He was not in a very pleasant mood; something
irritated him, and he manifested his ill humor by a little nervous twist
or jerk of the neck and head, peculiar to himself, accompanied by
some harshness of manner. This was perceived by me, and I hastily
concluded that my efforts to save him annoyance were not
appreciated. In disposing of some case of a vexatious character,
matters reached a climax; he became really worried, and, forgetting
what was due to my superior, I petulantly threw the paper down at
my side and gave evident signs of anger. Then, in a perfectly calm
and measured tone of voice, he said, 'Colonel Taylor, when I lose my
temper, don't you let it make you angry.'
"Was there ever a more gentle and considerate, and yet so
positive, reproof? How magnanimous in the great soldier, and yet
how crushing to the subordinate! The rash and disrespectful conduct
of the latter would have justified, if it did not demand, summary
treatment at the hands of the former. Instead of this, the first man
of his day and generation, great and glorious in his humility,
condescended to occupy the same plane with his youthful subaltern,
and to reason with him as an equal, frankly acknowledging his own
imperfections, but kindly reminding the inferior at the same time of
his duty and his position." Great indeed must be the man whom we
can love all the better for his human weakness.
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!

ebookultra.com

You might also like