Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
73432884
Commit
73432884
authored
Feb 20, 1998
by
Edmund Mergl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.7.01.7.0
parent
30b9b529
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
45 deletions
+48
-45
src/interfaces/perl5/eg/ApachePg.pl
src/interfaces/perl5/eg/ApachePg.pl
+27
-23
src/interfaces/perl5/eg/example.newstyle
src/interfaces/perl5/eg/example.newstyle
+15
-17
src/interfaces/perl5/eg/example.oldstyle
src/interfaces/perl5/eg/example.oldstyle
+6
-5
No files found.
src/interfaces/perl5/eg/ApachePg.pl
View file @
73432884
#!/usr/local/bin/perl
#!/usr/local/bin/perl
# demo script, tested with:
# demo script, tested with:
# - PostgreSQL-6.
2
# - PostgreSQL-6.
3
# - apache_1.
2.4
# - apache_1.
3
# - mod_perl-1.0
0
# - mod_perl-1.0
8
# - perl5.004_0
3
# - perl5.004_0
4
use
CGI
;
use
CGI
;
use
Pg
;
use
Pg
;
use
strict
;
$query
=
new
CGI
;
my
$query
=
new
CGI
;
print
$query
->
header
,
print
$query
->
header
,
$query
->
start_html
(
-
title
=>
'
A Simple Example
'),
$query
->
start_html
(
-
title
=>
'
A Simple Example
'),
$query
->
startform
,
$query
->
startform
,
"
<CENTER><H3>Testing Module Pg</H3></CENTER>
",
"
<CENTER><H3>Testing Module Pg</H3></CENTER>
",
"
Enter database name:
",
"
<P><CENTER><TABLE CELLPADDING=4 CELLSPACING=2 BORDER=1>
",
$query
->
textfield
(
-
name
=>
'
dbname
'),
"
<TR><TD>Enter conninfo string: </TD>
",
"
<P>
",
"
<TD>
",
$query
->
textfield
(
-
name
=>
'
conninfo
',
-
size
=>
40
,
-
default
=>
'
dbname=template1 host=localhost
'),
"
</TD>
",
"
Enter select command:
",
"
</TR>
",
$query
->
textfield
(
-
name
=>
'
cmd
',
-
size
=>
40
),
"
<TR><TD>Enter select command: </TD>
",
"
<P>
",
"
<TD>
",
$query
->
textfield
(
-
name
=>
'
cmd
',
-
size
=>
40
),
"
</TD>
",
$query
->
submit
(
-
value
=>
'
Submit
'),
"
</TR>
",
"
</TABLE></CENTER><P>
",
"
<CENTER>
",
$query
->
submit
(
-
value
=>
'
Submit
'),
"
</CENTER>
",
$query
->
endform
;
$query
->
endform
;
if
(
$query
->
param
)
{
if
(
$query
->
param
)
{
$dbname
=
$query
->
param
('
dbname
');
my
$conninfo
=
$query
->
param
('
conninfo
');
$conn
=
Pg::
connectdb
("
dbname =
$dbname
"
);
my
$conn
=
Pg::
connectdb
(
$conninfo
);
$cmd
=
$query
->
param
('
cmd
');
if
(
$conn
->
status
==
PGRES_CONNECTION_OK
)
{
$result
=
$conn
->
exec
(
$cmd
);
my
$cmd
=
$query
->
param
('
cmd
'
);
print
"
<TABLE>
"
;
my
$result
=
$conn
->
exec
(
$cmd
)
;
for
(
$i
=
0
;
$i
<
$result
->
ntuples
;
$i
++
)
{
print
"
<P><CENTER><TABLE CELLPADDING=4 CELLSPACING=2 BORDER=1>
\n
";
print
"
<TR>
"
;
my
@row
;
for
(
$j
=
0
;
$j
<
$result
->
nfields
;
$j
++
)
{
while
(
@row
=
$result
->
fetchrow
)
{
print
"
<T
D>
",
$result
->
getvalue
(
$i
,
$j
),
"
</TD>
";
print
"
<T
R><TD>
",
join
("
</TD><TD>
",
@row
),
"
</TD></TR>
\n
";
}
}
print
"
</TR>
";
print
"
</TABLE></CENTER><P>
\n
";
}
else
{
print
"
<CENTER><H2>Connect to database failed</H2></CENTER>
\n
";
}
}
print
"
</TABLE>
";
}
}
print
$query
->
end_html
;
print
$query
->
end_html
;
...
...
src/interfaces/perl5/eg/example.newstyle
View file @
73432884
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#-------------------------------------------------------
#-------------------------------------------------------
#
#
# $Id: example.newstyle,v 1.
2 1997/09/25 21:15:02
mergl Exp $
# $Id: example.newstyle,v 1.
3 1998/02/20 21:26:06
mergl Exp $
#
#
# Copyright (c) 1997 Edmund Mergl
# Copyright (c) 1997 Edmund Mergl
#
#
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
######################### We start with some black magic to print on failure.
######################### We start with some black magic to print on failure.
BEGIN
{
$|
=
1
;
print
"
1..
61
\n
";
}
BEGIN
{
$|
=
1
;
print
"
1..
57
\n
";
}
END
{
print
"
not ok 1
\n
"
unless
$loaded
;}
END
{
print
"
not ok 1
\n
"
unless
$loaded
;}
use
Pg
;
use
Pg
;
$loaded
=
1
;
$loaded
=
1
;
...
@@ -23,6 +23,7 @@ print "ok 1\n";
...
@@ -23,6 +23,7 @@ print "ok 1\n";
$dbmain
=
'
template1
';
$dbmain
=
'
template1
';
$dbname
=
'
pgperltest
';
$dbname
=
'
pgperltest
';
$dbhost
=
'
localhost
';
$trace
=
'
/tmp/pgtrace.out
';
$trace
=
'
/tmp/pgtrace.out
';
$cnt
=
2
;
$cnt
=
2
;
$DEBUG
=
0
;
# set this to 1 for traces
$DEBUG
=
0
;
# set this to 1 for traces
...
@@ -88,7 +89,7 @@ $SIG{PIPE} = sub { print "broken pipe\n" };
...
@@ -88,7 +89,7 @@ $SIG{PIPE} = sub { print "broken pipe\n" };
######################### create and connect to test database
######################### create and connect to test database
# 2-4
# 2-4
$conn
=
Pg::
connectdb
("
dbname=
$dbmain
");
$conn
=
Pg::
connectdb
("
dbname=
$dbmain
host=
$dbhost
");
cmp_eq
(
PGRES_CONNECTION_OK
,
$conn
->
status
);
cmp_eq
(
PGRES_CONNECTION_OK
,
$conn
->
status
);
# might fail if $dbname doesn't exist => don't check resultStatus
# might fail if $dbname doesn't exist => don't check resultStatus
...
@@ -97,7 +98,7 @@ $result = $conn->exec("DROP DATABASE $dbname");
...
@@ -97,7 +98,7 @@ $result = $conn->exec("DROP DATABASE $dbname");
$result
=
$conn
->
exec
("
CREATE DATABASE
$dbname
");
$result
=
$conn
->
exec
("
CREATE DATABASE
$dbname
");
cmp_eq
(
PGRES_COMMAND_OK
,
$result
->
resultStatus
);
cmp_eq
(
PGRES_COMMAND_OK
,
$result
->
resultStatus
);
$conn
=
Pg::
connectdb
("
dbname=
$dbname
");
$conn
=
Pg::
connectdb
("
dbname=
$dbname
host=
$dbhost
");
cmp_eq
(
PGRES_CONNECTION_OK
,
$conn
->
status
);
cmp_eq
(
PGRES_CONNECTION_OK
,
$conn
->
status
);
######################### debug, PQtrace
######################### debug, PQtrace
...
@@ -200,17 +201,14 @@ for ($k = 0; $k < $result->nfields; $k++) {
...
@@ -200,17 +201,14 @@ for ($k = 0; $k < $result->nfields; $k++) {
cmp_eq
(
$k
,
$fnumber
);
cmp_eq
(
$k
,
$fnumber
);
}
}
for
(
$k
=
0
;
$k
<
$result
->
ntuples
;
$k
++
)
{
$string
=
"";
$string
=
"";
while
(
@row
=
$result
->
fetchrow
)
{
for
(
$l
=
0
;
$l
<
$result
->
nfields
;
$l
++
)
{
$string
=
join
("
",
@row
);
$string
.=
$result
->
getvalue
(
$k
,
$l
)
.
"
";
}
$i
=
$k
+
1
;
cmp_eq
("
$i
Edmund Mergl
",
$string
);
}
}
cmp_eq
("
5 Edmund Mergl
",
$string
);
######################### PQnotifies
######################### PQnotifies
# 4
9-51
# 4
4-47
if
(
!
defined
(
$pid
=
fork
))
{
if
(
!
defined
(
$pid
=
fork
))
{
die
"
can not fork: $!
";
die
"
can not fork: $!
";
...
@@ -218,7 +216,7 @@ if (! defined($pid = fork)) {
...
@@ -218,7 +216,7 @@ if (! defined($pid = fork)) {
# i'm the child
# i'm the child
sleep
2
;
sleep
2
;
bless
$conn
;
bless
$conn
;
$conn
=
Pg::
connectdb
("
dbname=
$dbname
");
$conn
=
Pg::
connectdb
("
dbname=
$dbname
host=
$dbhost
");
$result
=
$conn
->
exec
("
NOTIFY person
");
$result
=
$conn
->
exec
("
NOTIFY person
");
exit
;
exit
;
}
}
...
@@ -236,7 +234,7 @@ while (1) {
...
@@ -236,7 +234,7 @@ while (1) {
cmp_eq
("
person
",
$table
);
cmp_eq
("
person
",
$table
);
######################### PQprint
######################### PQprint
#
52-53
#
48-49
$result
=
$conn
->
exec
("
SELECT name FROM person WHERE id = 2
");
$result
=
$conn
->
exec
("
SELECT name FROM person WHERE id = 2
");
cmp_eq
(
PGRES_TUPLES_OK
,
$result
->
resultStatus
);
cmp_eq
(
PGRES_TUPLES_OK
,
$result
->
resultStatus
);
...
@@ -246,7 +244,7 @@ $result->print(PRINT, 0, 0, 0, 0, 1, 0, " ", "", "", "myName");
...
@@ -246,7 +244,7 @@ $result->print(PRINT, 0, 0, 0, 0, 1, 0, " ", "", "", "myName");
close
(
PRINT
)
||
die
"
bad PRINT: $!
";
close
(
PRINT
)
||
die
"
bad PRINT: $!
";
######################### PQlo_import, PQlo_export, PQlo_unlink
######################### PQlo_import, PQlo_export, PQlo_unlink
# 5
4-59
# 5
0-55
$filename
=
'
ApachePg.pl
';
$filename
=
'
ApachePg.pl
';
$cwd
=
`
pwd
`;
$cwd
=
`
pwd
`;
...
@@ -276,9 +274,9 @@ if ($DEBUG) {
...
@@ -276,9 +274,9 @@ if ($DEBUG) {
}
}
######################### disconnect and drop test database
######################### disconnect and drop test database
#
60-61
#
56-57
$conn
= Pg::connectdb(
"
dbname
=
$dbmain
"
);
$conn
= Pg::connectdb(
"
dbname
=
$dbmain
host
=
$dbhost
"
);
cmp_eq(PGRES_CONNECTION_OK,
$conn
->status);
cmp_eq(PGRES_CONNECTION_OK,
$conn
->status);
$result
=
$conn
->exec(
"
DROP
DATABASE
$dbname
"
);
$result
=
$conn
->exec(
"
DROP
DATABASE
$dbname
"
);
...
...
src/interfaces/perl5/eg/example.oldstyle
View file @
73432884
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#-------------------------------------------------------
#-------------------------------------------------------
#
#
# $Id: example.oldstyle,v 1.
2 1997/09/25 21:15:04
mergl Exp $
# $Id: example.oldstyle,v 1.
3 1998/02/20 21:26:08
mergl Exp $
#
#
# Copyright (c) 1997 Edmund Mergl
# Copyright (c) 1997 Edmund Mergl
#
#
...
@@ -23,6 +23,7 @@ print "ok 1\n";
...
@@ -23,6 +23,7 @@ print "ok 1\n";
$dbmain
=
'
template1
';
$dbmain
=
'
template1
';
$dbname
=
'
pgperltest
';
$dbname
=
'
pgperltest
';
$dbhost
=
'
localhost
';
$trace
=
'
/tmp/pgtrace.out
';
$trace
=
'
/tmp/pgtrace.out
';
$cnt
=
2
;
$cnt
=
2
;
$DEBUG
=
0
;
# set this to 1 for traces
$DEBUG
=
0
;
# set this to 1 for traces
...
@@ -88,7 +89,7 @@ $SIG{PIPE} = sub { print "broken pipe\n" };
...
@@ -88,7 +89,7 @@ $SIG{PIPE} = sub { print "broken pipe\n" };
######################### create and connect to test database
######################### create and connect to test database
# 2-4
# 2-4
$conn
=
PQsetdb
(
''
,
'',
'',
'',
$dbmain
);
$conn
=
PQsetdb
(
$dbhost
,
'',
'',
'',
$dbmain
);
cmp_eq
(
PGRES_CONNECTION_OK
,
PQstatus
(
$conn
));
cmp_eq
(
PGRES_CONNECTION_OK
,
PQstatus
(
$conn
));
# might fail if $dbname doesn't exist => don't check resultStatus
# might fail if $dbname doesn't exist => don't check resultStatus
...
@@ -101,7 +102,7 @@ PQclear($result);
...
@@ -101,7 +102,7 @@ PQclear($result);
PQfinish
(
$conn
);
PQfinish
(
$conn
);
$conn
=
PQsetdb
(
''
,
'',
'',
'',
$dbname
);
$conn
=
PQsetdb
(
$dbhost
,
'',
'',
'',
$dbname
);
cmp_eq
(
PGRES_CONNECTION_OK
,
PQstatus
(
$conn
));
cmp_eq
(
PGRES_CONNECTION_OK
,
PQstatus
(
$conn
));
######################### debug, PQtrace
######################### debug, PQtrace
...
@@ -230,7 +231,7 @@ if (! defined($pid = fork)) {
...
@@ -230,7 +231,7 @@ if (! defined($pid = fork)) {
}
elsif
(
!
$pid
)
{
}
elsif
(
!
$pid
)
{
# i'm the child
# i'm the child
sleep
2
;
sleep
2
;
$conn
=
PQsetdb
(
''
,
'',
'',
'',
$dbname
);
$conn
=
PQsetdb
(
$dbhost
,
'',
'',
'',
$dbname
);
$result
=
PQexec
(
$conn
,
"
NOTIFY person
");
$result
=
PQexec
(
$conn
,
"
NOTIFY person
");
PQclear
(
$result
);
PQclear
(
$result
);
PQfinish
(
$conn
);
PQfinish
(
$conn
);
...
@@ -299,7 +300,7 @@ if ($DEBUG) {
...
@@ -299,7 +300,7 @@ if ($DEBUG) {
PQfinish(
$conn
);
PQfinish(
$conn
);
$conn
= PQsetdb(
''
, '', '', '',
$dbmain
);
$conn
= PQsetdb(
$dbhost
, '', '', '',
$dbmain
);
cmp_eq(PGRES_CONNECTION_OK, PQstatus(
$conn
));
cmp_eq(PGRES_CONNECTION_OK, PQstatus(
$conn
));
$result
= PQexec(
$conn
,
"
DROP
DATABASE
$dbname
"
);
$result
= PQexec(
$conn
,
"
DROP
DATABASE
$dbname
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment