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
dac40587
Commit
dac40587
authored
Sep 26, 1996
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated version.
parent
fd067981
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
34 deletions
+40
-34
contrib/pginterface/pginterface.c
contrib/pginterface/pginterface.c
+24
-17
contrib/pginterface/pginterface.h
contrib/pginterface/pginterface.h
+1
-1
contrib/pginterface/pgnulltest.c
contrib/pginterface/pgnulltest.c
+15
-16
No files found.
contrib/pginterface/pginterface.c
View file @
dac40587
...
@@ -99,15 +99,15 @@ PGresult *doquery(char *query)
...
@@ -99,15 +99,15 @@ PGresult *doquery(char *query)
int
fetch
(
void
*
param
,
...)
int
fetch
(
void
*
param
,
...)
{
{
va_list
ap
;
va_list
ap
;
int
arg
,
num_
arg
s
;
int
arg
,
num_
field
s
;
num_
arg
s
=
PQnfields
(
res
);
num_
field
s
=
PQnfields
(
res
);
if
(
tuple
>=
PQntuples
(
res
))
if
(
tuple
>=
PQntuples
(
res
))
return
END_OF_TUPLES
;
return
END_OF_TUPLES
;
va_start
(
ap
,
param
);
va_start
(
ap
,
param
);
for
(
arg
=
0
;
arg
<
num_
arg
s
;
arg
++
)
for
(
arg
=
0
;
arg
<
num_
field
s
;
arg
++
)
{
{
if
(
param
!=
NULL
)
if
(
param
!=
NULL
)
{
{
...
@@ -127,36 +127,43 @@ int fetch(void *param, ...)
...
@@ -127,36 +127,43 @@ int fetch(void *param, ...)
/*
/*
**
**
** fetch
isnull - returns tuple number (starts at 0), or the value END_OF_TUPLES
** fetch
withnulls - returns tuple number (starts at 0),
**
NULL pointers are skipped
**
or the value END_OF_TUPLES
** Returns true or false into null indicator variables
** Returns true or false into null indicator variables
** NULL pointers are skipped
*/
*/
int
fetch
isnull
(
void
*
param
,
...)
int
fetch
withnulls
(
void
*
param
,
...)
{
{
va_list
ap
;
va_list
ap
;
int
arg
,
num_
arg
s
;
int
arg
,
num_
field
s
;
if
(
tuple
==
0
)
num_fields
=
PQnfields
(
res
);
halt
(
"pginterface:fetchisnull(): You must call fetch() first.
\n
"
);
num_args
=
PQnfields
(
res
);
if
(
tuple
>=
PQntuples
(
res
))
if
(
tuple
-
1
>=
PQntuples
(
res
))
return
END_OF_TUPLES
;
return
END_OF_TUPLES
;
va_start
(
ap
,
param
);
va_start
(
ap
,
param
);
for
(
arg
=
0
;
arg
<
num_
arg
s
;
arg
++
)
for
(
arg
=
0
;
arg
<
num_
field
s
;
arg
++
)
{
{
if
(
param
!=
NULL
)
if
(
param
!=
NULL
)
{
{
if
(
PQgetisnull
(
res
,
tuple
-
1
,
arg
)
!=
0
)
if
(
PQfsize
(
res
,
arg
)
==
-
1
)
{
memcpy
(
param
,
PQgetvalue
(
res
,
tuple
,
arg
),
PQgetlength
(
res
,
tuple
,
arg
));
((
char
*
)
param
)[
PQgetlength
(
res
,
tuple
,
arg
)]
=
NUL
;
}
else
memcpy
(
param
,
PQgetvalue
(
res
,
tuple
,
arg
),
PQfsize
(
res
,
arg
));
}
param
=
va_arg
(
ap
,
char
*
);
if
(
PQgetisnull
(
res
,
tuple
,
arg
)
!=
0
)
*
(
int
*
)
param
=
1
;
*
(
int
*
)
param
=
1
;
else
else
*
(
int
*
)
param
=
0
;
*
(
int
*
)
param
=
0
;
}
param
=
va_arg
(
ap
,
char
*
);
param
=
va_arg
(
ap
,
char
*
);
}
}
va_end
(
ap
);
va_end
(
ap
);
return
tuple
-
1
;
return
tuple
++
;
}
}
/*
/*
...
...
contrib/pginterface/pginterface.h
View file @
dac40587
...
@@ -7,7 +7,7 @@ PGresult *doquery(char *query);
...
@@ -7,7 +7,7 @@ PGresult *doquery(char *query);
PGconn
*
connectdb
();
PGconn
*
connectdb
();
void
disconnectdb
();
void
disconnectdb
();
int
fetch
(
void
*
param
,
...);
int
fetch
(
void
*
param
,
...);
int
fetch
isnull
(
void
*
param
,
...);
int
fetch
withnulls
(
void
*
param
,
...);
void
on_error_continue
();
void
on_error_continue
();
void
on_error_stop
();
void
on_error_stop
();
...
...
contrib/pginterface/pgnulltest.c
View file @
dac40587
...
@@ -3,14 +3,14 @@
...
@@ -3,14 +3,14 @@
*
*
*/
*/
/*#define TEST_NON_NULLS*/
#define TEST_NON_NULLS
#include <stdio.h>
#include <stdio.h>
#include <signal.h>
#include <signal.h>
#include <time.h>
#include <time.h>
#include <halt.h>
#include <libpq-fe.h>
#include <libpq-fe.h>
#include "halt.h"
#include <pginterface.h>
#include "pginterface.h"
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
...
@@ -84,16 +84,25 @@ int main(int argc, char **argv)
...
@@ -84,16 +84,25 @@ int main(int argc, char **argv)
doquery
(
"FETCH ALL IN c_testfetch"
);
doquery
(
"FETCH ALL IN c_testfetch"
);
if
(
fetch
(
if
(
fetch
withnulls
(
&
aint
,
&
aint
,
&
aint_null
,
&
afloat
,
&
afloat
,
&
afloat_null
,
&
adouble
,
&
adouble
,
&
adouble_null
,
achar
,
achar
,
&
achar_null
,
achar16
,
achar16
,
&
achar16_null
,
abpchar
,
abpchar
,
&
abpchar_null
,
avarchar
,
avarchar
,
&
avarchar_null
,
atext
,
atext
,
&
aabstime
)
!=
END_OF_TUPLES
)
&
atext_null
,
&
aabstime
,
&
aabstime_null
)
!=
END_OF_TUPLES
)
printf
(
"int %d
\n
float %f
\n
double %f
\n
char %s
\n
char16 %s
\n
\
printf
(
"int %d
\n
float %f
\n
double %f
\n
char %s
\n
char16 %s
\n
\
bpchar %s
\n
varchar %s
\n
text %s
\n
abstime %s
\n
"
,
bpchar %s
\n
varchar %s
\n
text %s
\n
abstime %s
\n
"
,
aint
,
aint
,
...
@@ -105,16 +114,6 @@ bpchar %s\nvarchar %s\ntext %s\nabstime %s\n",
...
@@ -105,16 +114,6 @@ bpchar %s\nvarchar %s\ntext %s\nabstime %s\n",
avarchar
,
avarchar
,
atext
,
atext
,
ctime
(
&
aabstime
));
ctime
(
&
aabstime
));
if
(
fetchisnull
(
&
aint_null
,
&
afloat_null
,
&
adouble_null
,
&
achar_null
,
&
achar16_null
,
&
abpchar_null
,
&
avarchar_null
,
&
atext_null
,
&
aabstime_null
)
!=
END_OF_TUPLES
)
printf
(
"NULL:
\n
int %d
\n
float %d
\n
double %d
\n
char %d
\n
char16 %d
\n
\
printf
(
"NULL:
\n
int %d
\n
float %d
\n
double %d
\n
char %d
\n
char16 %d
\n
\
bpchar %d
\n
varchar %d
\n
text %d
\n
abstime %d
\n
"
,
bpchar %d
\n
varchar %d
\n
text %d
\n
abstime %d
\n
"
,
aint_null
,
aint_null
,
...
@@ -130,7 +129,7 @@ bpchar %d\nvarchar %d\ntext %d\nabstime %d\n",
...
@@ -130,7 +129,7 @@ bpchar %d\nvarchar %d\ntext %d\nabstime %d\n",
doquery
(
"CLOSE c_testfetch"
);
doquery
(
"CLOSE c_testfetch"
);
doquery
(
"COMMIT WORK"
);
doquery
(
"COMMIT WORK"
);
printf
(
"---
1 row inserted
\n
"
);
printf
(
"---
%-d rows inserted so far
\n
"
,
row
);
row
++
;
row
++
;
...
...
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