annotate main/database/inst/pq_connect.m @ 12720:52ca082757c2 octave-forge tip

Update copyright notices.
author i7tiol
date Sat, 27 Feb 2016 11:21:29 +0000
parents b3dfecfecbf4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12720
52ca082757c2 Update copyright notices.
i7tiol
parents: 12019
diff changeset
1 ## Copyright (C) 2012-2016 Olaf Till <i7tiol@t-online.de>
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
2 ##
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
3 ## This program is free software; you can redistribute it and/or modify it under
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
4 ## the terms of the GNU General Public License as published by the Free Software
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
5 ## Foundation; either version 3 of the License, or (at your option) any later
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
6 ## version.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
7 ##
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
11 ## details.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
12 ##
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
13 ## You should have received a copy of the GNU General Public License along with
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
15
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
16 ## -*- texinfo -*-
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
17 ## @deftypefn {Function File} {@var{connection} =} pq_connect (@var{settings})
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
18 ## Establishes a connection to a postgresql server according to
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
19 ## @var{settings} and returns an @code{octave_pq_connection} object
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
20 ## @var{connection} which can be passed to other functions of the
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
21 ## package. There can be multiple connections. An
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
22 ## @code{octave_pq_connection} object contains information on a
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
23 ## connection and will be internally altered by the packages functions
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
24 ## even though it is only passed as an argument, i.e. Octaves 'pass by
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
25 ## value' semantics are not adhered to in this case.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
26 ##
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
27 ## @var{settings} can be set by @code{setdbopts} (copied from Octaves
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
28 ## @code{optimset}) and can contain (defaults depend on Postgresql):
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
29 ## @code{host} (hostname), @code{hostaddr} (numeric host address),
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
30 ## @code{port} (port to connect to), @code{dbname} (database to connect
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
31 ## to), @code{user} (user name to connect as), @code{password},
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
32 ## @code{connect_timeout}, @code{options} (command-line options to send
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
33 ## to the server at run-time, see Postgresql documentation),
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
34 ## @code{sslmode} (@code{disable}, @code{allow}, @code{prefer},
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
35 ## @code{require}, @code{verify-ca}, or @code{verify-full}; see
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
36 ## Postgresql documentation of SSL support), @code{sslcert} (file name
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
37 ## of client SSL certificate), @code{sslkey} (location of secret key for
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
38 ## client certificate, file name or external OpenSSL engine
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
39 ## (colon-separated engine name and an engine-specific key identifier)),
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
40 ## @code{sslrootcert} (file name of root SSL certificate), @code{sslcrl}
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
41 ## (file name of SSL certificate revocation list), @code{krbsrvname}
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
42 ## (kerberos service name), @code{service} (service name in
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
43 ## pq_service.conf to use for additional parameters).
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
44 ##
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
45 ## All these settings are passed to the server as they are, so it may be
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
46 ## better to consult the postgresql documentation for them, e.g. the
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
47 ## documentation of the PQconnectdb function in libpq.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
48 ## @seealso {pq_exec_params, pq_update_types}
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
49 ## @end deftypefn
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
50
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
51 ## PKG_ADD: __all_db_opts__ ("pq_connect");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
52
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
53 function conn = pq_connect (settings)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
54
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
55 if (nargin != 1)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
56 print_usage ()
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
57 endif
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
58
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
59 if (ischar (settings) && strcmp (settings, "defaults"))
12019
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
60 conn = setdbopts ("host", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
61 "hostaddr", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
62 "port", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
63 "dbname", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
64 "user", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
65 "password", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
66 "connect_timeout", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
67 "options", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
68 "sslmode", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
69 "sslcert", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
70 "sslkey", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
71 "sslrootcert", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
72 "sslcrl", [], ...
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
73 "krbsrvname", [], ...
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
74 "service", []);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
75 return;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
76 endif
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
77
12019
b3dfecfecbf4 * tk_octave/inst/tk_dialog.m, tk_octave/inst/tk_scale.m,
jwe
parents: 11648
diff changeset
78 if (! isempty (to = getdbopts (settings, "connect_timeout")) && ...
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
79 isnumeric (to))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
80 settings = setdbopts (settings, "connect_timeout", num2str (to));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
81 endif
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
82
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
83 if (isfield (settings, "password") && isempty (settings.password))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
84 ## I know this is far from elegant, but it seems robust and I'm to
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
85 ## lazy now to find out a more decent way.
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
86 printf ("password: ");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
87 fflush (stdout);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
88 password = "";
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
89 while (true)
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
90 c = kbhit ();
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
91 if (c == "\n")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
92 printf ("\n");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
93 break;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
94 else
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
95 password = sprintf ("%s%s", password, c);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
96 endif
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
97 endwhile
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
98 settings.password = password;
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
99 endif
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
100
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
101 optstring = "";
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
102
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
103 for [val, key] = settings
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
104 if (isempty (val))
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
105 val = "";
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
106 endif
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
107 val = strrep (val, '\', '\\');
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
108 val = strrep (val, "'", "''");
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
109 optstring = sprintf ("%s%s='%s' ", optstring, key, val);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
110 endfor
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
111
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
112 conn = __pq_connect__ (optstring);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
113
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
114 endfunction
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
115
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
116 %!demo
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
117 %! conn = pq_connect (setdbopts ("dbname", "test"));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
118 %! pq_exec_params (conn, "create table testtable (t text, i int2, b bytea);")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
119 %! pq_exec_params (conn, "insert into testtable values ($1, $2, $3);", {"name1", 1, uint8([2, 4, 5])})
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
120 %! pq_exec_params (conn, "insert into testtable values ($1, $2, $3);", {"name2", 2, uint8([7, 9, 3, 1])})
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
121 %! pq_exec_params (conn, "select * from testtable;")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
122 %! pq_exec_params (conn, "drop table testtable;")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
123 %! pq_close (conn);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
124
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
125 %!demo
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
126 %! ## recursive type, array-composite-array
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
127 %! conn = pq_connect (setdbopts ("dbname", "test"));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
128 %! pq_exec_params (conn, "create type complex_bool_array_type as (b bool, ba bool[]);")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
129 %! pq_exec_params (conn, "create table complex_bool_array_array (a complex_bool_array_type[]);")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
130 %! pq_update_types (conn);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
131 %! pq_exec_params (conn, "insert into complex_bool_array_array values ($1);", {struct("ndims", 1, "data", {{{true, struct("ndims", 2, "data", {{true, false; true, true}})}; {false, struct("ndims", 1, "data", {{false; true}})}}})}, setdbopts ("param_types", {"complex_bool_array_type[]"}))
11648
567933605445 Add copy-in from variable to demos.
i7tiol
parents: 11394
diff changeset
132 %! data = pq_exec_params (conn, "select * from complex_bool_array_array;").data;
567933605445 Add copy-in from variable to demos.
i7tiol
parents: 11394
diff changeset
133 %! ## copy in from variable
567933605445 Add copy-in from variable to demos.
i7tiol
parents: 11394
diff changeset
134 %! pq_exec_params (conn, "copy complex_bool_array_array from stdin with binary;", setdbopts ("copy_in_data", data, "copy_in_from_variable", true, "copy_in_types", {"complex_bool_array_type[]"}))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
135 %! pq_exec_params (conn, "select * from complex_bool_array_array;")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
136 %! ## recursive type, composite-composite-array
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
137 %! pq_exec_params (conn, "create type complex_complex_bool_array_type as (b bool, c complex_bool_array_type);")
11648
567933605445 Add copy-in from variable to demos.
i7tiol
parents: 11394
diff changeset
138 %! pq_exec_params (conn, "create table complex_complex_bool_array (a complex_complex_bool_array_type);")
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
139 %! pq_update_types (conn);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
140 %! pq_exec_params (conn, "insert into complex_complex_bool_array values ($1);", {{false, {true, struct("ndims", 2, "data", {{true, false; true, true}})}}}, setdbopts ("param_types", {"complex_complex_bool_array_type"}))
11648
567933605445 Add copy-in from variable to demos.
i7tiol
parents: 11394
diff changeset
141 %! data = pq_exec_params (conn, "select * from complex_complex_bool_array").data;
567933605445 Add copy-in from variable to demos.
i7tiol
parents: 11394
diff changeset
142 %! ## copy in from variable
567933605445 Add copy-in from variable to demos.
i7tiol
parents: 11394
diff changeset
143 %! pq_exec_params (conn, "copy complex_complex_bool_array from stdin with binary;", setdbopts ("copy_in_data", data, "copy_in_from_variable", true, "copy_in_types", {"complex_complex_bool_array_type"}))
11394
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
144 %! pq_exec_params (conn, "select * from complex_complex_bool_array")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
145 %! pq_exec_params (conn, "drop table complex_complex_bool_array;")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
146 %! pq_exec_params (conn, "drop table complex_bool_array_array;")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
147 %! pq_exec_params (conn, "drop type complex_complex_bool_array_type;")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
148 %! pq_exec_params (conn, "drop type complex_bool_array_type;")
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
149 %! pq_close (conn);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
150
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
151 %!test
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
152 %! conn = pq_connect (setdbopts ("dbname", "test"));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
153 %! assert (islogical (t = pq_exec_params (conn, "select ($1);", {true}).data{1}) && t == true);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
154 %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {uint32(3)}).data{1}), "uint32 scalar") && t == 3);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
155 %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {.5}).data{1}), "scalar") && t == .5);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
156 %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {single(.5)}).data{1}), "float scalar") && t == .5);
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
157 %! assert ((strcmp (ti = typeinfo (t = pq_exec_params (conn, "select ($1);", {"abc"}).data{1}), "string") || strcmp (ti, "sq_string")) && strcmp (t, "abc"));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
158 %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {uint8([2, 3])}).data{1}), "uint8 matrix") && isequal (t, [2; 3]));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
159 %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {int16(-2)}).data{1}), "int16 scalar") && t == int16 (-2));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
160 %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {int32(-2)}).data{1}), "int32 scalar") && t == int32 (-2));
9aee227e296c Populated new database package with initial postgresql interface.
i7tiol
parents:
diff changeset
161 %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {int64(-2)}).data{1}), "int64 scalar") && t == int64 (-2));
12720
52ca082757c2 Update copyright notices.
i7tiol
parents: 12019
diff changeset
162 %! pq_close (conn);