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
87157899
Commit
87157899
authored
Jul 04, 2004
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made sure SET DESCRIPTOR accepts all data types including constants.
parent
a72dd7a9
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
161 additions
and
137 deletions
+161
-137
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+9
-0
src/interfaces/ecpg/ecpglib/data.c
src/interfaces/ecpg/ecpglib/data.c
+1
-4
src/interfaces/ecpg/ecpglib/descriptor.c
src/interfaces/ecpg/ecpglib/descriptor.c
+23
-30
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/execute.c
+95
-85
src/interfaces/ecpg/ecpglib/extern.h
src/interfaces/ecpg/ecpglib/extern.h
+2
-0
src/interfaces/ecpg/include/ecpglib.h
src/interfaces/ecpg/include/ecpglib.h
+1
-0
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+28
-15
src/interfaces/ecpg/preproc/variable.c
src/interfaces/ecpg/preproc/variable.c
+1
-1
src/interfaces/ecpg/test/test_desc.pgc
src/interfaces/ecpg/test/test_desc.pgc
+1
-2
No files found.
src/interfaces/ecpg/ChangeLog
View file @
87157899
...
...
@@ -1825,6 +1825,15 @@ Sun Jun 27 13:50:58 CEST 2004
Mon Jun 28 11:08:42 CEST 2004
- Arrays can be read as arrays or as character strings now.
Wed Jun 30 16:56:32 CEST 2004
- Added SET DESCRIPTOR command.
- Cleaned up error handling in preprocessor.
Sun Jul 4 16:53:53 CEST 2004
- Made sure SET DESCRIPTOR accepts all data types including constants.
- Set pgtypes library version to 1.2.
- Set ecpg version to 3.2.0.
- Set compat library version to 1.2.
...
...
src/interfaces/ecpg/ecpglib/data.c
View file @
87157899
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.2
5 2004/06/28 11:47:41
meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.2
6 2004/07/04 15:02:22
meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
...
...
@@ -76,10 +76,7 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
* and 0 if not
*/
if
(
PQgetisnull
(
results
,
act_tuple
,
act_field
))
{
printf
(
"MM NULL
\n
"
);
value_for_indicator
=
-
1
;
}
switch
(
ind_type
)
{
...
...
src/interfaces/ecpg/ecpglib/descriptor.c
View file @
87157899
/* dynamic SQL support routines
*
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.
9 2004/07/01 18:32:58
meskes Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.
10 2004/07/04 15:02:22
meskes Exp $
*/
#define POSTGRES_ECPG_INTERNAL
...
...
@@ -436,6 +436,7 @@ ECPGset_desc(int lineno, char *desc_name, int index,...)
va_list
args
;
struct
descriptor
*
desc
;
struct
descriptor_item
*
desc_item
;
struct
variable
*
var
;
for
(
desc
=
all_descriptors
;
desc
;
desc
=
desc
->
next
)
{
...
...
@@ -463,69 +464,59 @@ ECPGset_desc(int lineno, char *desc_name, int index,...)
desc
->
items
=
desc_item
;
}
if
(
!
(
var
=
(
struct
variable
*
)
ECPGalloc
(
sizeof
(
struct
variable
),
lineno
)))
return
false
;
va_start
(
args
,
index
);
do
{
enum
ECPGdtype
itemtype
;
long
varcharsize
;
long
offset
;
long
arrsize
;
enum
ECPGttype
vartype
;
void
*
var
;
enum
ECPGttype
type
;
const
char
*
tobeinserted
=
NULL
;
bool
malloced
;
itemtype
=
va_arg
(
args
,
enum
ECPGdtype
);
if
(
itemtype
==
ECPGd_EODT
)
break
;
vartype
=
va_arg
(
args
,
enum
ECPGttype
);
var
=
va_arg
(
args
,
void
*
);
varcharsize
=
va_arg
(
args
,
long
);
arrsize
=
va_arg
(
args
,
long
);
offset
=
va_arg
(
args
,
long
);
type
=
va_arg
(
args
,
enum
ECPGttype
);
ECPGget_variable
(
&
args
,
type
,
var
,
false
);
switch
(
itemtype
)
{
case
ECPGd_data
:
{
// FIXME: how to do this in general?
switch
(
vartype
)
if
(
!
ECPGstore_input
(
lineno
,
true
,
var
,
&
tobeinserted
,
&
malloced
))
{
case
ECPGt_char
:
desc_item
->
data
=
strdup
((
char
*
)
var
);
break
;
case
ECPGt_int
:
{
char
buf
[
20
];
snprintf
(
buf
,
20
,
"%d"
,
*
(
int
*
)
var
);
desc_item
->
data
=
strdup
(
buf
);
break
;
}
default:
abort
();
ECPGfree
(
var
);
return
false
;
}
desc_item
->
data
=
(
char
*
)
tobeinserted
;
tobeinserted
=
NULL
;
break
;
}
case
ECPGd_indicator
:
set_int_item
(
lineno
,
&
desc_item
->
indicator
,
var
,
var
type
);
set_int_item
(
lineno
,
&
desc_item
->
indicator
,
var
->
pointer
,
var
->
type
);
break
;
case
ECPGd_length
:
set_int_item
(
lineno
,
&
desc_item
->
length
,
var
,
var
type
);
set_int_item
(
lineno
,
&
desc_item
->
length
,
var
->
pointer
,
var
->
type
);
break
;
case
ECPGd_precision
:
set_int_item
(
lineno
,
&
desc_item
->
precision
,
var
,
var
type
);
set_int_item
(
lineno
,
&
desc_item
->
precision
,
var
->
pointer
,
var
->
type
);
break
;
case
ECPGd_scale
:
set_int_item
(
lineno
,
&
desc_item
->
scale
,
var
,
var
type
);
set_int_item
(
lineno
,
&
desc_item
->
scale
,
var
->
pointer
,
var
->
type
);
break
;
case
ECPGd_type
:
set_int_item
(
lineno
,
&
desc_item
->
type
,
var
,
var
type
);
set_int_item
(
lineno
,
&
desc_item
->
type
,
var
->
pointer
,
var
->
type
);
break
;
default:
...
...
@@ -533,6 +524,7 @@ ECPGset_desc(int lineno, char *desc_name, int index,...)
char
type_str
[
20
];
snprintf
(
type_str
,
sizeof
(
type_str
),
"%d"
,
itemtype
);
ECPGraise
(
lineno
,
ECPG_UNKNOWN_DESCRIPTOR_ITEM
,
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
,
type_str
);
ECPGfree
(
var
);
return
false
;
}
}
...
...
@@ -544,6 +536,7 @@ ECPGset_desc(int lineno, char *desc_name, int index,...)
}*/
}
while
(
true
);
ECPGfree
(
var
);
return
true
;
}
...
...
src/interfaces/ecpg/ecpglib/execute.c
View file @
87157899
This diff is collapsed.
Click to expand it.
src/interfaces/ecpg/ecpglib/extern.h
View file @
87157899
...
...
@@ -124,6 +124,8 @@ PGresult **ECPGdescriptor_lvalue (int line, const char *descriptor);
bool
ECPGstore_result
(
const
PGresult
*
results
,
int
act_field
,
const
struct
statement
*
stmt
,
struct
variable
*
var
);
bool
ECPGstore_input
(
const
int
,
const
bool
,
const
struct
variable
*
,
const
char
**
,
bool
*
);
void
ECPGget_variable
(
va_list
*
,
enum
ECPGttype
,
struct
variable
*
,
bool
);
/* SQLSTATE values generated or processed by ecpglib (intentionally
* not exported -- users should refer to the codes directly) */
...
...
src/interfaces/ecpg/include/ecpglib.h
View file @
87157899
...
...
@@ -8,6 +8,7 @@
#include "libpq-fe.h"
#include "ecpgtype.h"
#include <string.h>
#ifndef __BEOS__
#ifndef __cplusplus
...
...
src/interfaces/ecpg/preproc/preproc.y
View file @
87157899
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.29
0 2004/06/30 15:01:57
meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.29
1 2004/07/04 15:02:23
meskes Exp $ */
/* Copyright comment */
%{
...
...
@@ -504,7 +504,7 @@ add_additional_variables(char *name, bool insert)
%type <str> AlterUserSetStmt privilege_list privilege privilege_target
%type <str> opt_grant_grant_option opt_revoke_grant_option cursor_options
%type <str> transaction_mode_list_or_empty transaction_mode_list
%type <str> function_with_argtypes_list function_with_argtypes
%type <str> function_with_argtypes_list function_with_argtypes
IntConstVar
%type <str> DropdbStmt ClusterStmt grantee RevokeStmt Bit DropOpClassStmt
%type <str> GrantStmt privileges PosAllConst constraints_set_list
%type <str> ConstraintsSetStmt AllConst CreateDomainStmt opt_nowait
...
...
@@ -4204,6 +4204,17 @@ IntConst: PosIntConst { $$ = $1; }
| '-' PosIntConst { $$ = cat2_str(make_str("-"), $2); }
;
IntConstVar: Iconst
{
char *length = mm_alloc(32);
sprintf(length, "%d", (int) strlen($1));
new_variable($1, ECPGmake_simple_type(ECPGt_const, length), 0);
$$ = $1;
}
| cvariable { $$ = $1; }
;
StringConst: Sconst { $$ = $1; }
| civar { $$ = $1; }
;
...
...
@@ -5283,8 +5294,8 @@ opt_output: SQL_OUTPUT { $$ = make_str("output"); }
/*
* dynamic SQL: descriptor based access
* written by Christof Petig <christof.petig@wtal.de>
* and Peter Eisentraut <peter.eisentraut@credativ.de>
*
originall
written by Christof Petig <christof.petig@wtal.de>
*
and Peter Eisentraut <peter.eisentraut@credativ.de>
*/
/*
...
...
@@ -5319,7 +5330,7 @@ ECPGGetDescHeaderItems: ECPGGetDescHeaderItem
| ECPGGetDescHeaderItems ',' ECPGGetDescHeaderItem
;
ECPGGetDescHeaderItem:
CVARIABLE
'=' desc_header_item
ECPGGetDescHeaderItem:
cvariable
'=' desc_header_item
{ push_assignment($1, $3); }
;
...
...
@@ -5331,8 +5342,10 @@ ECPGSetDescHeaderItems: ECPGSetDescHeaderItem
| ECPGSetDescHeaderItems ',' ECPGSetDescHeaderItem
;
ECPGSetDescHeaderItem: desc_header_item '=' CVARIABLE
{ push_assignment($3, $1); }
ECPGSetDescHeaderItem: desc_header_item '=' IntConstVar
{
push_assignment($3, $1);
}
;
...
...
@@ -5343,9 +5356,7 @@ desc_header_item: SQL_COUNT { $$ = ECPGd_count; }
* manipulate a descriptor
*/
ECPGGetDescriptor: GET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE CVARIABLE ECPGGetDescItems
{ $$.str = $5; $$.name = $3; }
| GET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE Iconst ECPGGetDescItems
ECPGGetDescriptor: GET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE IntConstVar ECPGGetDescItems
{ $$.str = $5; $$.name = $3; }
;
...
...
@@ -5353,12 +5364,10 @@ ECPGGetDescItems: ECPGGetDescItem
| ECPGGetDescItems ',' ECPGGetDescItem
;
ECPGGetDescItem:
CVARIABLE
'=' descriptor_item { push_assignment($1, $3); };
ECPGGetDescItem:
cvariable
'=' descriptor_item { push_assignment($1, $3); };
ECPGSetDescriptor: SET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE CVARIABLE ECPGSetDescItems
{ $$.str = $5; $$.name = $3; }
| SET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE Iconst ECPGSetDescItems
ECPGSetDescriptor: SET SQL_DESCRIPTOR quoted_ident_stringvar SQL_VALUE IntConstVar ECPGSetDescItems
{ $$.str = $5; $$.name = $3; }
;
...
...
@@ -5366,7 +5375,11 @@ ECPGSetDescItems: ECPGSetDescItem
| ECPGSetDescItems ',' ECPGSetDescItem
;
ECPGSetDescItem: descriptor_item '=' CVARIABLE { push_assignment($3, $1); };
ECPGSetDescItem: descriptor_item '=' IntConstVar
{
push_assignment($3, $1);
}
;
descriptor_item: SQL_CARDINALITY { $$ = ECPGd_cardinality; }
...
...
src/interfaces/ecpg/preproc/variable.c
View file @
87157899
...
...
@@ -419,7 +419,7 @@ dump_variables(struct arguments * list, int mode)
/* Then the current element and its indicator */
ECPGdump_a_type
(
yyout
,
list
->
variable
->
name
,
list
->
variable
->
type
,
list
->
indicator
->
name
,
list
->
indicator
->
type
,
NULL
,
NULL
,
0
,
NULL
,
NULL
);
NULL
,
NULL
,
make_str
(
"0"
)
,
NULL
,
NULL
);
/* Then release the list element. */
if
(
mode
!=
0
)
...
...
src/interfaces/ecpg/test/test_desc.pgc
View file @
87157899
...
...
@@ -31,8 +31,7 @@ main()
EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
//EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1output;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
...
...
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