~ubuntu-branches/ubuntu/precise/postgresql-9.1/precise-security

« back to all changes in this revision

Viewing changes to src/interfaces/ecpg/test/expected/connect-test5.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Processed by ecpg (regression mode) */
 
2
/* These include files are added by the preprocessor */
 
3
#include <ecpglib.h>
 
4
#include <ecpgerrno.h>
 
5
#include <sqlca.h>
 
6
/* End of automatic include section */
 
7
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
 
8
 
 
9
#line 1 "test5.pgc"
 
10
/*
 
11
 * this file tests all sorts of connecting to one single database.
 
12
 */
 
13
 
 
14
#include <stdlib.h>
 
15
#include <string.h>
 
16
#include <stdlib.h>
 
17
#include <stdio.h>
 
18
 
 
19
/* do not include regression.h */
 
20
 
 
21
int
 
22
main(void)
 
23
{
 
24
/* exec sql begin declare section */
 
25
         
 
26
         
 
27
         
 
28
 
 
29
#line 16 "test5.pgc"
 
30
 char db [ 200 ] ;
 
31
 
 
32
#line 17 "test5.pgc"
 
33
 char id [ 200 ] ;
 
34
 
 
35
#line 18 "test5.pgc"
 
36
 char * user = "connectuser" ;
 
37
/* exec sql end declare section */
 
38
#line 19 "test5.pgc"
 
39
 
 
40
 
 
41
        ECPGdebug(1, stderr);
 
42
 
 
43
        { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
 
44
#line 23 "test5.pgc"
 
45
 
 
46
        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user connectuser encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);}
 
47
#line 24 "test5.pgc"
 
48
 
 
49
        { ECPGdisconnect(__LINE__, "CURRENT");}
 
50
#line 25 "test5.pgc"
 
51
  /* <-- "main" not specified */
 
52
 
 
53
        strcpy(db, "connectdb");
 
54
        strcpy(id, "main");
 
55
        { ECPGconnect(__LINE__, 0, db , NULL, NULL , id, 0); }
 
56
#line 29 "test5.pgc"
 
57
 
 
58
        { ECPGdisconnect(__LINE__, id);}
 
59
#line 30 "test5.pgc"
 
60
 
 
61
 
 
62
        { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
 
63
#line 32 "test5.pgc"
 
64
 
 
65
        { ECPGdisconnect(__LINE__, "main");}
 
66
#line 33 "test5.pgc"
 
67
 
 
68
 
 
69
        { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
 
70
#line 35 "test5.pgc"
 
71
 
 
72
        { ECPGdisconnect(__LINE__, "main");}
 
73
#line 36 "test5.pgc"
 
74
 
 
75
 
 
76
        { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
 
77
#line 38 "test5.pgc"
 
78
 
 
79
        { ECPGdisconnect(__LINE__, "main");}
 
80
#line 39 "test5.pgc"
 
81
 
 
82
 
 
83
        { ECPGconnect(__LINE__, 0, "" , "connectdb" , NULL , "main", 0); }
 
84
#line 41 "test5.pgc"
 
85
 
 
86
        { ECPGdisconnect(__LINE__, "main");}
 
87
#line 42 "test5.pgc"
 
88
 
 
89
 
 
90
        { ECPGconnect(__LINE__, 0, "connectdb" , "connectuser" , "connectdb" , "main", 0); }
 
91
#line 44 "test5.pgc"
 
92
 
 
93
        { ECPGdisconnect(__LINE__, "main");}
 
94
#line 45 "test5.pgc"
 
95
 
 
96
 
 
97
        { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
 
98
#line 47 "test5.pgc"
 
99
 
 
100
        { ECPGdisconnect(__LINE__, "main");}
 
101
#line 48 "test5.pgc"
 
102
 
 
103
 
 
104
        { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , "connectuser" , NULL , "main", 0); }
 
105
#line 50 "test5.pgc"
 
106
 
 
107
        { ECPGdisconnect(__LINE__, "main");}
 
108
#line 51 "test5.pgc"
 
109
 
 
110
 
 
111
        { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/connectdb" , user , NULL , "main", 0); }
 
112
#line 53 "test5.pgc"
 
113
 
 
114
        { ECPGdisconnect(__LINE__, "main");}
 
115
#line 54 "test5.pgc"
 
116
 
 
117
 
 
118
        { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/connectdb" , "connectuser" , NULL , "main", 0); }
 
119
#line 56 "test5.pgc"
 
120
 
 
121
        { ECPGdisconnect(__LINE__, "main");}
 
122
#line 57 "test5.pgc"
 
123
 
 
124
 
 
125
        { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "connectdb" , NULL , "main", 0); }
 
126
#line 59 "test5.pgc"
 
127
 
 
128
        { ECPGdisconnect(__LINE__, "main");}
 
129
#line 60 "test5.pgc"
 
130
 
 
131
 
 
132
        /* connect twice */
 
133
        { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
 
134
#line 63 "test5.pgc"
 
135
 
 
136
        { ECPGconnect(__LINE__, 0, "connectdb" , NULL, NULL , "main", 0); }
 
137
#line 64 "test5.pgc"
 
138
 
 
139
        { ECPGdisconnect(__LINE__, "main");}
 
140
#line 65 "test5.pgc"
 
141
 
 
142
 
 
143
        /* not connected */
 
144
        { ECPGdisconnect(__LINE__, "nonexistant");}
 
145
#line 68 "test5.pgc"
 
146
 
 
147
 
 
148
        return (0);
 
149
}