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
4aa1734f
Commit
4aa1734f
authored
Nov 09, 1996
by
Marc G. Fournier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added in PQconnectdb() function
Submitted by: wieck@sapserv.debis.de (Jan Wieck)
parent
7ee9464b
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
549 additions
and
41 deletions
+549
-41
src/Makefile.global
src/Makefile.global
+3
-3
src/interfaces/libpgtcl/pgtcl.c
src/interfaces/libpgtcl/pgtcl.c
+6
-1
src/interfaces/libpgtcl/pgtclCmds.c
src/interfaces/libpgtcl/pgtclCmds.c
+89
-33
src/interfaces/libpgtcl/pgtclCmds.h
src/interfaces/libpgtcl/pgtclCmds.h
+3
-1
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-connect.c
+423
-2
src/interfaces/libpq/libpq-fe.h
src/interfaces/libpq/libpq-fe.h
+25
-1
No files found.
src/Makefile.global
View file @
4aa1734f
...
...
@@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/Attic/Makefile.global,v 1.5
6 1996/11/08 07:47:5
2 scrappy Exp $
# $Header: /cvsroot/pgsql/src/Attic/Makefile.global,v 1.5
7 1996/11/09 10:39:0
2 scrappy Exp $
#
# NOTES
# This is seen by any Makefiles that include mk/postgres.mk. To
...
...
@@ -59,7 +59,7 @@
# to change it in Makefile.custom.
# make sure that you have no whitespaces after the PORTNAME setting
# or the makefiles can get confused
PORTNAME
=
UNDEFINED
PORTNAME
=
BSD44_derived
# Ignore LINUX_ELF if you're not using Linux. But if you are, and you're
# compiling to a.out (which means you're using the dld dynamic loading
...
...
@@ -860,7 +860,7 @@ includedir= $(HEADERDIR)
# Flags for CC and LD. (depend on COPT and PROFILE)
#
# PostgreSQL should *always* compile with -Wall -Werror enabled
CFLAGS
+=
-Wall
-Werror
CFLAGS
+=
-Wall
#
-Werror
# Globally pass debugging/optimization/profiling flags based
# on the options selected above.
...
...
src/interfaces/libpgtcl/pgtcl.c
View file @
4aa1734f
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.
3 1996/10/30 06:18:38
scrappy Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.
4 1996/11/09 10:39:40
scrappy Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -75,6 +75,11 @@ Pgtcl_Init (Tcl_Interp *interp)
Tcl_CreateExitHandler
(
Pgtcl_AtExit
,
(
ClientData
)
cd
);
/* register all pgtcl commands */
Tcl_CreateCommand
(
interp
,
"pg_conndefaults"
,
Pg_conndefaults
,
(
ClientData
)
cd
,
(
Tcl_CmdDeleteProc
*
)
NULL
);
Tcl_CreateCommand
(
interp
,
"pg_connect"
,
Pg_connect
,
...
...
src/interfaces/libpgtcl/pgtclCmds.c
View file @
4aa1734f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.
5 1996/10/30 06:18:39
scrappy Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.
6 1996/11/09 10:39:41
scrappy Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -209,6 +209,44 @@ tcl_value (char *value)
#endif
/**********************************
* pg_conndefaults
syntax:
pg_conndefaults
the return result is a list describing the possible options and their
current default values for a call to pg_connect with the new -conninfo
syntax. Each entry in the list is a sublist of the format:
{optname label dispchar dispsize value}
**********************************/
int
Pg_conndefaults
(
ClientData
cData
,
Tcl_Interp
*
interp
,
int
argc
,
char
*
argv
[])
{
PQconninfoOption
*
option
;
char
buf
[
8192
];
Tcl_ResetResult
(
interp
);
for
(
option
=
PQconndefaults
();
option
->
keyword
!=
NULL
;
option
++
)
{
if
(
option
->
val
==
NULL
)
{
option
->
val
=
""
;
}
sprintf
(
buf
,
"{%s} {%s} {%s} %d {%s}"
,
option
->
keyword
,
option
->
label
,
option
->
dispchar
,
option
->
dispsize
,
option
->
val
);
Tcl_AppendElement
(
interp
,
buf
);
}
return
TCL_OK
;
}
/**********************************
* pg_connect
make a connection to a backend.
...
...
@@ -235,55 +273,73 @@ Pg_connect(ClientData cData, Tcl_Interp *interp, int argc, char* argv[])
if
(
argc
==
1
)
{
Tcl_AppendResult
(
interp
,
"pg_connect: database name missing
\n
"
,
0
);
Tcl_AppendResult
(
interp
,
"pg_connect databaseName [-host hostName] [-port portNumber] [-tty pgtty]]"
,
0
);
Tcl_AppendResult
(
interp
,
"pg_connect databaseName [-host hostName] [-port portNumber] [-tty pgtty]]
\n
"
,
0
);
Tcl_AppendResult
(
interp
,
"pg_connect -conninfo <conninfo-string>"
,
0
);
return
TCL_ERROR
;
}
if
(
argc
>
2
)
{
/* parse for pg environment settings */
i
=
2
;
while
(
i
+
1
<
argc
)
{
if
(
strcmp
(
argv
[
i
],
"-host"
)
==
0
)
{
pghost
=
argv
[
i
+
1
];
i
+=
2
;
}
else
if
(
strcmp
(
argv
[
i
],
"-port"
)
==
0
)
{
pgport
=
argv
[
i
+
1
];
if
(
!
strcmp
(
"-conninfo"
,
argv
[
1
]))
{
/*
* Establish a connection using the new PQconnectdb() interface
*/
if
(
argc
!=
3
)
{
Tcl_AppendResult
(
interp
,
"pg_connect: syntax error
\n
"
,
0
);
Tcl_AppendResult
(
interp
,
"pg_connect -conninfo <conninfo-string>"
,
0
);
return
TCL_ERROR
;
}
conn
=
PQconnectdb
(
argv
[
2
]);
}
else
{
/*
* Establish a connection using the old PQsetdb() interface
*/
if
(
argc
>
2
)
{
/* parse for pg environment settings */
i
=
2
;
while
(
i
+
1
<
argc
)
{
if
(
strcmp
(
argv
[
i
],
"-host"
)
==
0
)
{
pghost
=
argv
[
i
+
1
];
i
+=
2
;
}
else
if
(
strcmp
(
argv
[
i
],
"-
tty
"
)
==
0
)
{
pg
tty
=
argv
[
i
+
1
];
if
(
strcmp
(
argv
[
i
],
"-
port
"
)
==
0
)
{
pg
port
=
argv
[
i
+
1
];
i
+=
2
;
}
else
if
(
strcmp
(
argv
[
i
],
"-options"
)
==
0
)
{
pgoptions
=
argv
[
i
+
1
];
i
+=
2
;
}
else
{
Tcl_AppendResult
(
interp
,
"Bad option to pg_connect :
\n
"
,
argv
[
i
],
0
);
Tcl_AppendResult
(
interp
,
"pg_connect databaseName [-host hostName] [-port portNumber] [-tty pgtty]]"
,
0
);
return
TCL_ERROR
;
}
}
/* while */
if
((
i
%
2
!=
0
)
||
i
!=
argc
)
{
Tcl_AppendResult
(
interp
,
"wrong # of arguments to pg_connect
\n
"
,
argv
[
i
],
0
);
Tcl_AppendResult
(
interp
,
"pg_connect databaseName [-host hostName] [-port portNumber] [-tty pgtty]]"
,
0
);
return
TCL_ERROR
;
else
if
(
strcmp
(
argv
[
i
],
"-tty"
)
==
0
)
{
pgtty
=
argv
[
i
+
1
];
i
+=
2
;
}
else
if
(
strcmp
(
argv
[
i
],
"-options"
)
==
0
)
{
pgoptions
=
argv
[
i
+
1
];
i
+=
2
;
}
else
{
Tcl_AppendResult
(
interp
,
"Bad option to pg_connect :
\n
"
,
argv
[
i
],
0
);
Tcl_AppendResult
(
interp
,
"pg_connect databaseName [-host hostName] [-port portNumber] [-tty pgtty]]"
,
0
);
return
TCL_ERROR
;
}
}
/* while */
if
((
i
%
2
!=
0
)
||
i
!=
argc
)
{
Tcl_AppendResult
(
interp
,
"wrong # of arguments to pg_connect
\n
"
,
argv
[
i
],
0
);
Tcl_AppendResult
(
interp
,
"pg_connect databaseName [-host hostName] [-port portNumber] [-tty pgtty]]"
,
0
);
return
TCL_ERROR
;
}
}
dbName
=
argv
[
1
];
conn
=
PQsetdb
(
pghost
,
pgport
,
pgoptions
,
pgtty
,
dbName
);
}
dbName
=
argv
[
1
];
conn
=
PQsetdb
(
pghost
,
pgport
,
pgoptions
,
pgtty
,
dbName
);
if
(
conn
->
status
==
CONNECTION_OK
)
{
PgSetConnectionId
(
cd
,
interp
->
result
,
conn
);
return
TCL_OK
;
}
else
{
Tcl_AppendResult
(
interp
,
"Connection to
"
,
dbName
,
"
failed
\n
"
,
0
);
Tcl_AppendResult
(
interp
,
"Connection to
database
failed
\n
"
,
0
);
Tcl_AppendResult
(
interp
,
conn
->
errorMessage
,
0
);
PQfinish
(
conn
);
return
TCL_ERROR
;
}
}
...
...
src/interfaces/libpgtcl/pgtclCmds.h
View file @
4aa1734f
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pgtclCmds.h,v 1.
3 1996/10/30 06:18:40
scrappy Exp $
* $Id: pgtclCmds.h,v 1.
4 1996/11/09 10:39:42
scrappy Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -43,6 +43,8 @@ typedef struct Pg_ResultId_s {
/* **************************/
/* registered Tcl functions */
/* **************************/
extern
int
Pg_conndefaults
(
ClientData
cData
,
Tcl_Interp
*
interp
,
int
argc
,
char
*
argv
[]);
extern
int
Pg_connect
(
ClientData
cData
,
Tcl_Interp
*
interp
,
int
argc
,
char
*
argv
[]);
extern
int
Pg_disconnect
(
...
...
src/interfaces/libpq/fe-connect.c
View file @
4aa1734f
This diff is collapsed.
Click to expand it.
src/interfaces/libpq/libpq-fe.h
View file @
4aa1734f
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-fe.h,v 1.
9 1996/11/04 04:00:56 momjian
Exp $
* $Id: libpq-fe.h,v 1.
10 1996/11/09 10:39:54 scrappy
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -146,8 +146,31 @@ struct _PQprintOpt {
typedef
struct
_PQprintOpt
PQprintOpt
;
/* ----------------
* Structure for the conninfo parameter definitions of PQconnectdb()
* ----------------
*/
struct
_PQconninfoOption
{
char
*
keyword
;
/* The keyword of the option */
char
*
environ
;
/* Fallback environment variable name */
char
*
compiled
;
/* Fallback compiled in default value */
char
*
val
;
/* Options value */
char
*
label
;
/* Label for field in connect dialog */
char
*
dispchar
;
/* Character to display for this field */
/* in a connect dialog. Values are: */
/* "" Display entered value as is */
/* "*" Password field - hide value */
/* "D" Debug options - don't */
/* create a field by default */
int
dispsize
;
/* Field size in characters for dialog */
};
typedef
struct
_PQconninfoOption
PQconninfoOption
;
/* === in fe-connect.c === */
/* make a new client connection to the backend */
extern
PGconn
*
PQconnectdb
(
const
char
*
conninfo
);
extern
PQconninfoOption
*
PQconndefaults
();
extern
PGconn
*
PQsetdb
(
const
char
*
pghost
,
const
char
*
pgport
,
const
char
*
pgoptions
,
const
char
*
pgtty
,
const
char
*
dbName
);
/* close the current connection and free the PGconn data structure */
...
...
@@ -157,6 +180,7 @@ extern void PQfinish(PGconn* conn);
extern
void
PQreset
(
PGconn
*
conn
);
extern
char
*
PQdb
(
PGconn
*
conn
);
extern
char
*
PQuser
(
PGconn
*
conn
);
extern
char
*
PQhost
(
PGconn
*
conn
);
extern
char
*
PQoptions
(
PGconn
*
conn
);
extern
char
*
PQport
(
PGconn
*
conn
);
...
...
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