mirror of https://github.com/postgres/postgres
parent
95563e7bbf
commit
339a5bbfb1
@ -0,0 +1,72 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* pg_type.h |
||||
* definition of the system "type" relation (pg_type) |
||||
* along with the relation's initial contents. |
||||
* |
||||
* |
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* $Id: pg_type.h,v 1.1 2000/09/20 13:25:51 meskes Exp $ |
||||
* |
||||
* NOTES |
||||
* the genbki.sh script reads this file and generates .bki |
||||
* information from the DATA() statements. |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef PG_TYPE_H |
||||
#define PG_TYPE_H |
||||
|
||||
/* ----------------
|
||||
* initial contents of pg_type |
||||
* ---------------- |
||||
*/ |
||||
|
||||
/* keep the following ordered by OID so that later changes can be made easier*/ |
||||
|
||||
/* OIDS 1 - 99 */ |
||||
#define BOOLOID 16 |
||||
#define BYTEAOID 17 |
||||
#define CHAROID 18 |
||||
#define NAMEOID 19 |
||||
#define INT8OID 20 |
||||
#define INT2OID 21 |
||||
#define INT2VECTOROID 22 |
||||
#define INT4OID 23 |
||||
#define REGPROCOID 24 |
||||
#define TEXTOID 25 |
||||
#define OIDOID 26 |
||||
#define TIDOID 27 |
||||
#define XIDOID 28 |
||||
#define CIDOID 29 |
||||
#define OIDVECTOROID 30 |
||||
#define POINTOID 600 |
||||
#define LSEGOID 601 |
||||
#define PATHOID 602 |
||||
#define BOXOID 603 |
||||
#define POLYGONOID 604 |
||||
#define LINEOID 628 |
||||
#define FLOAT4OID 700 |
||||
#define FLOAT8OID 701 |
||||
#define ABSTIMEOID 702 |
||||
#define RELTIMEOID 703 |
||||
#define TINTERVALOID 704 |
||||
#define UNKNOWNOID 705 |
||||
#define CIRCLEOID 718 |
||||
#define CASHOID 790 |
||||
#define INETOID 869 |
||||
#define CIDROID 650 |
||||
#define BPCHAROID 1042 |
||||
#define VARCHAROID 1043 |
||||
#define DATEOID 1082 |
||||
#define TIMEOID 1083 |
||||
#define TIMESTAMPOID 1184 |
||||
#define INTERVALOID 1186 |
||||
#define TIMETZOID 1266 |
||||
#define ZPBITOID 1560 |
||||
#define VARBITOID 1562 |
||||
#define NUMERICOID 1700 |
||||
|
||||
#endif /* PG_TYPE_H */ |
@ -0,0 +1,51 @@ |
||||
// $Id: test_code100.pgc,v 1.1 2000/09/20 13:25:52 meskes Exp $ |
||||
|
||||
exec sql include sqlca; |
||||
#include <stdio.h> |
||||
|
||||
int main(int argc, char **argv) |
||||
{ exec sql begin declare section; |
||||
int index; |
||||
exec sql end declare section; |
||||
|
||||
|
||||
// ECPGdebug(1,stdout); |
||||
|
||||
exec sql connect to test; |
||||
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql create table test ( |
||||
"index" numeric(3) primary key, |
||||
"payload" int4 NOT NULL); |
||||
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
exec sql commit work; |
||||
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
for (index=0;index<10;++index) |
||||
{ exec sql insert into test |
||||
(payload, index) |
||||
values (0, :index); |
||||
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
} |
||||
exec sql commit work; |
||||
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql update test |
||||
set payload=payload+1 where index=-1; |
||||
if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql delete from test where index=-1; |
||||
if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql insert into test (select * from test where index=-1); |
||||
if (sqlca.sqlcode!=100) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql drop table test; |
||||
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
exec sql commit work; |
||||
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql disconnect; |
||||
if (sqlca.sqlcode) printf("%ld:%s\n",sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
return 0; |
||||
} |
@ -0,0 +1,61 @@ |
||||
exec sql include sqlca; |
||||
|
||||
int fa() { return 2; } |
||||
int fb(int x) { return x; } |
||||
int fc(const char *x) { return *x; } |
||||
int fd(const char *x,int i) { return (*x)*i; } |
||||
enum e { ENUM0, ENUM1 }; |
||||
int fe(enum e x) { return (int)x; } |
||||
struct sa { int member; }; |
||||
|
||||
void sqlmeldung(char *meldung, short trans) |
||||
{ |
||||
} |
||||
|
||||
#define NO 0 |
||||
#define YES 1 |
||||
|
||||
#ifdef _cplusplus |
||||
namespace N |
||||
{ static const int i=2; |
||||
}; |
||||
#endif |
||||
|
||||
int main() |
||||
{ struct sa x,*y; |
||||
exec sql begin declare section; |
||||
int a=2; |
||||
int b=2+2; |
||||
int d=x.member; |
||||
int g=fb(2); |
||||
int i=3^1; |
||||
int j=1?1:2; |
||||
|
||||
/*int e=y->member; /* compile error */ |
||||
/*int c=10>>2; /* compile error */ |
||||
/*bool h=2||1; /* compile error */ |
||||
exec sql end declare section; |
||||
|
||||
/* not working */ |
||||
int f=fa(); |
||||
|
||||
#ifdef _cplusplus |
||||
exec sql begin declare section; |
||||
int k=N::i; /* compile error */ |
||||
exec sql end declare section; |
||||
#endif |
||||
|
||||
exec sql whenever sqlerror do fa(); |
||||
exec sql select now(); |
||||
exec sql whenever sqlerror do fb(20); |
||||
exec sql select now(); |
||||
exec sql whenever sqlerror do fc("50"); |
||||
exec sql select now(); |
||||
exec sql whenever sqlerror do fd("50",1); |
||||
exec sql select now(); |
||||
exec sql whenever sqlerror do fe(ENUM0); |
||||
exec sql select now(); |
||||
/* ex ec sql whenever sqlerror do sqlmeldung(NULL,NO); */ |
||||
exec sql select now(); |
||||
return 0; |
||||
} |
Binary file not shown.
@ -0,0 +1,94 @@ |
||||
// $Id: test_notice.pgc,v 1.1 2000/09/20 13:25:52 meskes Exp $ |
||||
|
||||
exec sql include sqlca; |
||||
|
||||
#include <stdio.h> |
||||
|
||||
void printwarning(void) |
||||
{ |
||||
if (sqlca.sqlwarn[0]) printf("sqlca.sqlwarn: %c",sqlca.sqlwarn[0]); |
||||
else return; |
||||
|
||||
if (sqlca.sqlwarn[1]) putchar('1'); |
||||
if (sqlca.sqlwarn[2]) putchar('2'); |
||||
|
||||
putchar('\n'); |
||||
} |
||||
|
||||
int main(int argc, char **argv) |
||||
{ |
||||
exec sql begin declare section; |
||||
int index,payload; |
||||
exec sql end declare section; |
||||
FILE *dbgs; |
||||
|
||||
/* actually this will print 'sql error' if a warning occurs */ |
||||
exec sql whenever sqlwarning do printwarning(); |
||||
|
||||
if ((dbgs = fopen("log", "w")) != NULL) |
||||
ECPGdebug(1, dbgs); |
||||
|
||||
exec sql connect to mm; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql create table test ( |
||||
"index" numeric(3) primary key, |
||||
"payload" int4 NOT NULL); |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql commit work; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql begin work; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql begin work; |
||||
if (sqlca.sqlcode!=ECPG_NOTICE_IN_TRANSACTION) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql commit; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql commit; |
||||
if (sqlca.sqlcode!=ECPG_NOTICE_NO_TRANSACTION) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql rollback; |
||||
if (sqlca.sqlcode!=ECPG_NOTICE_NO_TRANSACTION) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
sqlca.sqlcode=0; |
||||
exec sql declare x cursor for select * from test; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql open x; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql open x; |
||||
if (sqlca.sqlcode!=ECPG_NOTICE_PORTAL_EXISTS) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql close x; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql close x; |
||||
if (sqlca.sqlcode!=ECPG_NOTICE_UNKNOWN_PORTAL) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql update test set nonexistent=2; |
||||
if (sqlca.sqlcode!=ECPG_PGSQL) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql select payload into :payload from test where index=1; |
||||
if (sqlca.sqlcode!=ECPG_NOTICE_QUERY_IGNORED) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql rollback; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
// this will raise a warning |
||||
exec sql drop table test; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
exec sql commit work; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
exec sql disconnect; |
||||
if (sqlca.sqlcode) printf("%d %ld:%s\n",__LINE__,sqlca.sqlcode,sqlca.sqlerrm.sqlerrmc); |
||||
|
||||
if (dbgs != NULL) |
||||
fclose(dbgs); |
||||
return 0; |
||||
} |
Loading…
Reference in new issue