./PaxHeaders.8241/database-2.4.40000644000000000000000000000013213444726064013032 xustar0030 mtime=1553181748.551490686 30 atime=1553181803.415144792 30 ctime=1553181803.415144792 database-2.4.4/0000755000175000017500000000000013444726064013223 5ustar00olafolaf00000000000000database-2.4.4/PaxHeaders.8241/src0000644000000000000000000000013213444726153013463 xustar0030 mtime=1553181803.415144792 30 atime=1553181803.415144792 30 ctime=1553181803.415144792 database-2.4.4/src/0000755000175000017500000000000013444726153014011 5ustar00olafolaf00000000000000database-2.4.4/src/PaxHeaders.8241/aclocal.m40000644000000000000000000000013113444726065015401 xustar0030 mtime=1553181749.507952814 29 atime=1553181749.68662884 30 ctime=1553181803.415144792 database-2.4.4/src/aclocal.m40000644000175000017500000000127113444726065015654 0ustar00olafolaf00000000000000# generated automatically by aclocal 1.15 -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_include([m4/octave-forge.m4]) database-2.4.4/src/PaxHeaders.8241/m40000644000000000000000000000013213444726064014004 xustar0030 mtime=1553181748.634790561 30 atime=1553181803.415144792 30 ctime=1553181803.415144792 database-2.4.4/src/m4/0000755000175000017500000000000013444726064014332 5ustar00olafolaf00000000000000database-2.4.4/src/m4/PaxHeaders.8241/octave-forge.m40000644000000000000000000000013213444726064016704 xustar0030 mtime=1553181748.634790561 30 atime=1553181749.142659606 30 ctime=1553181803.415144792 database-2.4.4/src/m4/octave-forge.m40000644000175000017500000000575313444726064017167 0ustar00olafolaf00000000000000# Copyright (C) 2017 Olaf Till # Modifications to print what is searching for by JohnD # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # arguments of OF_OCTAVE_ALT_SYMS (see also description of # OF_OCTAVE_LIST_ALT_SYMS below): # # $1: symbol version 1 # $2: symbol version 2 # $3: test for symbol version 2 # $4: macro name to access alternative symbols # $5: include directives for symbol version 1 # $6: include directives for symbol version 2 # (a list of lists of args 1--6 is $1 of OF_OCTAVE_LIST_ALT_SYMS) # $7: name of generated include file with alternatives of Octave headers # (arg7 is $2 of OF_OCTAVE_LIST_ALT_SYMS) AC_DEFUN([OF_OCTAVE_ALT_SYMS], [ AC_MSG_CHECKING([$1 or $2]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include ] $6], [$3])], [AC_DEFINE($4, [[$2]], [macro for alternative Octave symbols]) AC_MSG_RESULT([$2]) echo '$6' >> $7], [AC_DEFINE($4, [[$1]], [macro for alternative Octave symbols]) AC_MSG_RESULT([$1]) echo '$5' >> $7] ) ]) # OF_OCTAVE_LIST_ALT_SYMS is called in the following way: # # OF_OCTAVE_LIST_ALT_SYMS([ # [dnl # [old_octave_symbol], # [new_octave_symbol], # [[compilation test] # [for new_octave_symbol]], # [NAME_OF_GENERATED_MACRO____WILL_EXPAND_TO_OLD_OR_NEW_SYMBOL], # [[include directives] # [except #include ] # [necessary to compile with old_octave_symbol]], # [[include directives] # [except #include ] # [nessary to compile with new_octave_symbol] # [and to compile the test]] # ], # # ... further such lists as the above # # ], # # [name-of-header-file-for-alternative-octave-iclude-directives.h]) # # # This file should be put into src/m4/, and the line # # AC_CONFIG_MACRO_DIRS([m4]) # # should be put into src/configure.ac. The package should use # autoheader to generate config.h.in (src/bootstrap should contain the # lines 'aclocal', 'autoconf', and 'autoheader -f'). Package code # should include config.h and use the generated macros to access the # alternative symbols of Octave. An example of a call to # OF_OCTAVE_LIST_ALT_SYMS in src/configure.ac is available together # with this file. AC_DEFUN([OF_OCTAVE_LIST_ALT_SYMS], [ echo '/* generated by configure */' > $2 m4_foreach([it], [$1], [m4_apply([OF_OCTAVE_ALT_SYMS], [it, $2])]) AH_BOTTOM([#include "$2"]) ]) database-2.4.4/src/PaxHeaders.8241/munge-texi.pl0000644000000000000000000000013213444726064016160 xustar0030 mtime=1553181748.634790561 30 atime=1553181802.082987012 30 ctime=1553181803.415144792 database-2.4.4/src/munge-texi.pl0000755000175000017500000001176513444726064016446 0ustar00olafolaf00000000000000#!/usr/bin/perl -w # # Copyright (C) 2012-2014 Rik Wehbring # # This file is part of Octave. # # Octave is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3 of the License, or (at # your option) any later version. # # Octave is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License # along with Octave; see the file COPYING. If not, see # . # copied from Octave and slightly modified by Olaf Till # Validate program call die "usage: munge-texi DOCSTRING-FILE ... < file" if (@ARGV < 1); # Constant patterns $doc_delim = qr/^\x{1d}/; $tex_delim = qr/\Q-*- texinfo -*-\E/; $comment_line = qr/^\s*(?:$|#)/; # Pre-declare hash size for efficiency keys(%help_text) = 1800; ################################################################################ # Load DOCSTRINGS into memory while expanding @seealso references foreach $DOCSTRING_file (@ARGV) { open (DOCFH, $DOCSTRING_file) or die "Unable to open $DOCSTRING_file\n"; # Skip comments while (defined ($_ = ) and /$comment_line/o) {;} # Validate DOCSTRING file format die "invalid doc file format\n" if (! /$doc_delim/o); do { s/\s*$//; # strip EOL character(s) $symbol = substr ($_,1); $docstring = extract_docstring (); if ($help_text{$symbol}) { warn "ignoring duplicate entry for $symbol\n"; } else { $help_text{$symbol} = $docstring; } } while (! eof); } ################################################################################ # Process .txi to .texi by expanding @DOCSTRING, @EXAMPLEFILE macros # Add warning header print '@c This file is generated automatically by the packages munge-texi.pl.',"\n\n"; # parse ../DESCRIPTION to get package version open (FH, "../DESCRIPTION") or die "unable to open file ../DESCRIPTION\n"; while () { # this represents the current logic of pkg if (/^Version\s*:\s*([^\s]+)/i) { $version = $1; } } close (FH); defined ($version) or die "unable to find version string in ../DESCRIPTION\n"; TXI_LINE: while () { if (/^\s*\@DOCSTRING\((\S+)\)/) { $func = $1; $docstring = $help_text{$func}; if (! $docstring) { warn "no docstring entry for $func\n"; next TXI_LINE; } $func =~ s/^@/@@/; # Texinfo uses @@ to produce '@' $docstring =~ s/^$tex_delim$/\@anchor{XREF$func}/m; print $docstring,"\n"; next TXI_LINE; } if (/^\s*\@DOCSTRINGVERBATIM\((\S+)\)/) { $func = $1; $docstring = $help_text{$func}; if (! $docstring) { warn "no docstring entry for $func\n"; next TXI_LINE; } $func =~ s/^@/@@/; # Texinfo uses @@ to produce '@' print '@anchor',"{XREF$func}\n"; $docstring =~ s/^@[cC] .*?\n//; print '@verbatim',"\n"; print $docstring,"\n"; print '@end verbatim',"\n"; next TXI_LINE; } if (/^\s*\@EXAMPLEFILE\((\S+)\)/) { $fname = "$1"; print '@verbatim',"\n"; open (EXAMPFH, $fname) or die "unable to open example file $fname\n"; while () { print $_; print "\n" if (eof and substr ($_, -1) ne "\n"); } close (EXAMPFH); print '@end verbatim',"\n\n"; next TXI_LINE; } # replace @PACKAGEVERSION with version string s/\@PACKAGEVERSION/$version/o; # pass ordinary lines straight through to output print $_; } ################################################################################ # Subroutines ################################################################################ sub extract_docstring { my ($docstring, $arg_list, $func_list, $repl, $rest_of_line); $cut = 0; DOC_LINE: while (defined ($_ = ) and ! /$doc_delim/o) { # drop text marked for cutting out if (/^\s*\@[cC]\s*BEGIN_CUT_TEXINFO\s*$/) { die "BEGIN_CUT_TEXINFO not matched by END_CUT_TEXINFO" if ($cut); $cut = 1; next DOC_LINE; } if (/^\s*\@[cC]\s*END_CUT_TEXINFO\s*$/) { die "END_CUT_TEXINFO without BEGIN_CUT_TEXINFO" if (! $cut); $cut = 0; next DOC_LINE; } if ($cut) { next DOC_LINE; } # expand any @seealso references if (m'^@seealso\s*{') { # Join multiple lines until full macro body found while (! /}/m) { $_ .= ; } ($arg_list, $rest_of_line) = m'^@seealso\s*{(.*)}(.*)?'s; $func_list = $arg_list; $func_list =~ s/\s+//gs; $repl = ""; foreach $func (split (/,/, $func_list)) { $func =~ s/^@/@@/; # Texinfo uses @@ to produce '@' $repl .= "\@ref{XREF$func,,$func}, "; } substr($repl,-2) = ""; # Remove last ', ' $_ = "\@seealso{$repl}$rest_of_line"; } $docstring .= $_; } return $docstring; } database-2.4.4/src/PaxHeaders.8241/configure0000644000000000000000000000013213444726065015446 xustar0030 mtime=1553181749.901040071 30 atime=1553181750.246693341 30 ctime=1553181803.415144792 database-2.4.4/src/configure0000755000175000017500000047460013444726065015735 0ustar00olafolaf00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for database 2.4.4. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and i7tiol@t-online.de $0: about your system, including any error possibly output $0: before this message. Then install a modern shell, or $0: manually run the script under such a shell if you do $0: have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='database' PACKAGE_TARNAME='database' PACKAGE_VERSION='2.4.4' PACKAGE_STRING='database 2.4.4' PACKAGE_BUGREPORT='i7tiol@t-online.de' PACKAGE_URL='' ac_unique_file="__pq_connect__.cc" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS EGREP GREP LIBOBJS ac_ct_CC CFLAGS CC CXXCPP OBJEXT EXEEXT ac_ct_CXX CPPFLAGS LDFLAGS CXXFLAGS CXX SED AWK PG_CONFIG OCTAVE_CONFIG MKOCTFILE target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir runstatedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking ' ac_precious_vars='build_alias host_alias target_alias CXX CXXFLAGS LDFLAGS LIBS CPPFLAGS CCC CXXCPP CC CFLAGS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -runstatedir | --runstatedir | --runstatedi | --runstated \ | --runstate | --runstat | --runsta | --runst | --runs \ | --run | --ru | --r) ac_prev=runstatedir ;; -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ | --run=* | --ru=* | --r=*) runstatedir=$ac_optarg ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures database 2.4.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/database] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of database 2.4.4:";; esac cat <<\_ACEOF Some influential environment variables: CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXXCPP C++ preprocessor CC C compiler command CFLAGS C compiler flags Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF database configure 2.4.4 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_cxx_try_cpp LINENO # ------------------------ # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_cpp # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_cxx_try_link LINENO # ------------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_link # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_cxx_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## --------------------------------- ## ## Report this to i7tiol@t-online.de ## ## --------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_mongrel # ac_fn_cxx_try_run LINENO # ------------------------ # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_cxx_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_run # ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_cxx_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_cxx_check_header_compile cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by database $as_me 2.4.4, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" # Avoid warnings for redefining AH-generated preprocessor symbols of # Octave. # Checks for programs. # Extract the first word of "mkoctfile", so it can be a program name with args. set dummy mkoctfile; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MKOCTFILE+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MKOCTFILE"; then ac_cv_prog_MKOCTFILE="$MKOCTFILE" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MKOCTFILE="mkoctfile" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MKOCTFILE=$ac_cv_prog_MKOCTFILE if test -n "$MKOCTFILE"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKOCTFILE" >&5 $as_echo "$MKOCTFILE" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$MKOCTFILE"; then as_fn_error 1 "mkoctfile not found" "$LINENO" 5; fi # Extract the first word of "octave-config", so it can be a program name with args. set dummy octave-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OCTAVE_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OCTAVE_CONFIG"; then ac_cv_prog_OCTAVE_CONFIG="$OCTAVE_CONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OCTAVE_CONFIG="octave-config" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OCTAVE_CONFIG=$ac_cv_prog_OCTAVE_CONFIG if test -n "$OCTAVE_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OCTAVE_CONFIG" >&5 $as_echo "$OCTAVE_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$OCTAVE_CONFIG"; then as_fn_error 1 "octave-config not found" "$LINENO" 5; fi # Extract the first word of "pg_config", so it can be a program name with args. set dummy pg_config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_PG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PG_CONFIG"; then ac_cv_prog_PG_CONFIG="$PG_CONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_PG_CONFIG="pg_config" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi PG_CONFIG=$ac_cv_prog_PG_CONFIG if test -n "$PG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PG_CONFIG" >&5 $as_echo "$PG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$PG_CONFIG"; then as_fn_error 1 "pg_config not found" "$LINENO" 5; fi for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done if test -z "$ac_cv_prog_AWK"; then as_fn_error 1 "AWK not found" "$LINENO" 5; fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed # The same value of CXX as Octave was compiled with is supposed to be used. CXX=${CXX:-`${MKOCTFILE} -p CXX`} ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 $as_echo_n "checking whether the C++ compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C++ compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 $as_echo_n "checking for C++ compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 $as_echo_n "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then if ${ac_cv_prog_CXXCPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 $as_echo "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_cxx_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Checks for libraries. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQconnectdb in -lpq" >&5 $as_echo_n "checking for PQconnectdb in -lpq... " >&6; } if ${ac_cv_lib_pq_PQconnectdb+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpq $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char PQconnectdb (); int main () { return PQconnectdb (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pq_PQconnectdb=yes else ac_cv_lib_pq_PQconnectdb=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQconnectdb" >&5 $as_echo "$ac_cv_lib_pq_PQconnectdb" >&6; } if test "x$ac_cv_lib_pq_PQconnectdb" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPQ 1 _ACEOF LIBS="-lpq $LIBS" else as_fn_error $? "unable to find the PQconnectdb() function in pq" "$LINENO" 5 fi # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for error_at_line" >&5 $as_echo_n "checking for error_at_line... " >&6; } if ${ac_cv_lib_error_at_line+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { error_at_line (0, 0, "", 0, "an error occurred"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_error_at_line=yes else ac_cv_lib_error_at_line=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_error_at_line" >&5 $as_echo "$ac_cv_lib_error_at_line" >&6; } if test $ac_cv_lib_error_at_line = no; then case " $LIBOBJS " in *" error.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS error.$ac_objext" ;; esac fi # Check for PostgreSQL version. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether PostgreSQL version >= 8.3" >&5 $as_echo_n "checking whether PostgreSQL version >= 8.3... " >&6; } if `$PG_CONFIG --version | awk 'NR==1 { print $(NF); };' | awk -F '.' ' { if ( $1 > 8 || $1 == 8 && $2 >= 3 ) exit 1; else exit 0}'`; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error 1 "package \"database\" does not work with PostgreSQL version < 8.3" "$LINENO" 5; else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi # Start of checks for Octave features, preparations for checks. OCTLIBDIR=${OCTLIBDIR:-`$OCTAVE_CONFIG -p OCTLIBDIR`} ## We need Octaves include path both with and without '/octave' ## appended. The path without '/octave' is needed to selectively test ## for Octave headers, like octave/....h. The path with '/octave' is ## needed since some Octave headers contain include directives for ## other Octave headers with <> instead of "". OCTINCLUDEDIR=${OCTINCLUDEDIR:-`$MKOCTFILE -p INCFLAGS`} ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu TCXXFLAGS=$CXXFLAGS TLDFLAGS=$LDFLAGS TLIBS=$LIBS TCPPFLAGS=$CPPFLAGS LDFLAGS="-L$OCTLIBDIR $LDFLAGS" LIBS="-loctinterp $LIBS" # CXXFLAGS= CPPFLAGS="$OCTINCLUDEDIR $CPPFLAGS" ## Presence of 'error_state' -- does _not_ indicate no exceptions are ## used. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { printf ("%i", error_state); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : $as_echo "#define HAVE_OCTAVE_ERROR_STATE 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ## Presence of 'verror (octave(_|::)execution_exception&, const char *, ## va_list)' cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave_execution_exception e; va_list args; verror (e, "test", args); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define HAVE_OCTAVE_VERROR_ARG_EXC 1" >>confdefs.h else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave::execution_exception e; va_list args; verror (e, "test", args); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define HAVE_OCTAVE_VERROR_ARG_EXC 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_cxx_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_cxx_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in octave/interpreter.h do : ac_fn_cxx_check_header_mongrel "$LINENO" "octave/interpreter.h" "ac_cv_header_octave_interpreter_h" "$ac_includes_default" if test "x$ac_cv_header_octave_interpreter_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_OCTAVE_INTERPRETER_H 1 _ACEOF fi done ## Simple symbol alternatives of different Octave versions. echo '/* generated by configure */' > oct-alt-includes.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking oct_mach_info or octave::mach_info" >&5 $as_echo_n "checking oct_mach_info or octave::mach_info... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave::mach_info::flt_fmt_unknown; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OCTAVE__MACH_INFO octave::mach_info" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: octave::mach_info" >&5 $as_echo "octave::mach_info" >&6; } echo ' ' >> oct-alt-includes.h else $as_echo "#define OCTAVE__MACH_INFO oct_mach_info" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: oct_mach_info" >&5 $as_echo " oct_mach_info" >&6; } echo '' >> oct-alt-includes.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking is_cell or iscell" >&5 $as_echo_n "checking is_cell or iscell... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave_value ().iscell (); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OV_ISCELL iscell" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: iscell" >&5 $as_echo "iscell" >&6; } echo ' ' >> oct-alt-includes.h else $as_echo "#define OV_ISCELL is_cell" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: is_cell" >&5 $as_echo " is_cell" >&6; } echo '' >> oct-alt-includes.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking is_empty or isempty" >&5 $as_echo_n "checking is_empty or isempty... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave_value ().isempty (); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OV_ISEMPTY isempty" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: isempty" >&5 $as_echo "isempty" >&6; } echo ' ' >> oct-alt-includes.h else $as_echo "#define OV_ISEMPTY is_empty" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: is_empty" >&5 $as_echo " is_empty" >&6; } echo '' >> oct-alt-includes.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking is_float_type or isfloat" >&5 $as_echo_n "checking is_float_type or isfloat... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave_value ().isfloat (); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OV_ISFLOAT isfloat" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: isfloat" >&5 $as_echo "isfloat" >&6; } echo ' ' >> oct-alt-includes.h else $as_echo "#define OV_ISFLOAT is_float_type" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: is_float_type" >&5 $as_echo " is_float_type" >&6; } echo '' >> oct-alt-includes.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking is_integer_type or isinteger" >&5 $as_echo_n "checking is_integer_type or isinteger... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave_value ().isinteger (); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OV_ISINTEGER isinteger" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: isinteger" >&5 $as_echo "isinteger" >&6; } echo ' ' >> oct-alt-includes.h else $as_echo "#define OV_ISINTEGER is_integer_type" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: is_integer_type" >&5 $as_echo " is_integer_type" >&6; } echo '' >> oct-alt-includes.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking is_real_type or isreal" >&5 $as_echo_n "checking is_real_type or isreal... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave_value ().isreal (); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OV_ISREAL isreal" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: isreal" >&5 $as_echo "isreal" >&6; } echo ' ' >> oct-alt-includes.h else $as_echo "#define OV_ISREAL is_real_type" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: is_real_type" >&5 $as_echo " is_real_type" >&6; } echo '' >> oct-alt-includes.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking feval or octave::feval" >&5 $as_echo_n "checking feval or octave::feval... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { octave::feval ("date"); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OCTAVE__FEVAL octave::feval" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: octave::feval" >&5 $as_echo "octave::feval" >&6; } echo '#include ' >> oct-alt-includes.h else $as_echo "#define OCTAVE__FEVAL feval" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: feval" >&5 $as_echo " feval" >&6; } echo '#include ' >> oct-alt-includes.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking octave_execution_exception or octave::execution_exception" >&5 $as_echo_n "checking octave_execution_exception or octave::execution_exception... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { octave::execution_exception (); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OCTAVE__EXECUTION_EXCEPTION octave::execution_exception" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: octave::execution_exception" >&5 $as_echo "octave::execution_exception" >&6; } echo ' ' >> oct-alt-includes.h else $as_echo "#define OCTAVE__EXECUTION_EXCEPTION octave_execution_exception" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: octave_execution_exception" >&5 $as_echo " octave_execution_exception" >&6; } echo '' >> oct-alt-includes.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking octave_vformat or octave::vformat" >&5 $as_echo_n "checking octave_vformat or octave::vformat... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { std::ostringstream obuf; va_list args; octave::vformat (obuf, "dummy", args); ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : $as_echo "#define OCTAVE__VFORMAT octave::vformat" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: octave::vformat" >&5 $as_echo "octave::vformat" >&6; } echo ' ' >> oct-alt-includes.h else $as_echo "#define OCTAVE__VFORMAT octave_vformat" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: octave_vformat" >&5 $as_echo " octave_vformat" >&6; } echo '' >> oct-alt-includes.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext LIBS=$TLIBS LDFLAGS=$TLDFLAGS CXXFLAGS=$TCXXFLAGS CPPFLAGS=$TCPPFLAGS ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # End of checks for Octave features. ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by database $as_me 2.4.4, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ database config.status 2.4.4 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi database-2.4.4/src/PaxHeaders.8241/error-helpers.cc0000644000000000000000000000013213444726064016641 xustar0030 mtime=1553181748.607023936 30 atime=1553181748.607023936 30 ctime=1553181803.415144792 database-2.4.4/src/error-helpers.cc0000644000175000017500000000256513444726064017122 0ustar00olafolaf00000000000000/* Copyright (C) 2016-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include "error-helpers.h" // call verror #ifdef HAVE_OCTAVE_VERROR_ARG_EXC void c_verror (OCTAVE__EXECUTION_EXCEPTION& e, const char *fmt, ...) { va_list args; va_start (args, fmt); verror (e, fmt, args); va_end (args); } #else void c_verror (const OCTAVE__EXECUTION_EXCEPTION&, const char *fmt, ...) { va_list args; va_start (args, fmt); verror (fmt, args); va_end (args); } #endif void _p_error (const char *fmt, ...) { va_list args; va_start (args, fmt); std::ostringstream output_buf; OCTAVE__VFORMAT (output_buf, fmt, args); std::string msg = output_buf.str (); if (msg[msg.length () - 1] != '\n') msg += "\n"; std::cerr << msg; va_end (args); } database-2.4.4/src/PaxHeaders.8241/pq_exec.cc0000644000000000000000000000013113444726064015473 xustar0030 mtime=1553181748.642723882 29 atime=1553181800.05866577 30 ctime=1553181803.415144792 database-2.4.4/src/pq_exec.cc0000644000175000017500000002353413444726064015754 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include #include #include #include "command.h" #include "error-helpers.h" // PKG_disabled_ADD: autoload ("pq_exec", "pq_interface.oct"); // PKG_disabled_DEL: autoload ("pq_exec", "pq_interface.oct", "remove"); // PKG_ADD: autoload ("__pq_exec_params__", "pq_interface.oct"); // PKG_DEL: autoload ("__pq_exec_params__", "pq_interface.oct", "remove"); #if 0 // I left this here because of its (formerly working) functionality of // reading more than one result. But the code (and the helptext, too) // has not been adapted to general changes and is not working, and it // would need converters for text mode to be useful. Anyway I don't // see why one should need to execute many commands with one line, // except if one wants to use some unchanged external SQL code. I'll // probably wait till someone expresses such a need. DEFUN_DLD (pq_exec, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{id}} pq_exec (@var{connection}, @var{command})\n\ @deftypefnx {Loadable Function} {@var{id}} pq_exec (@var{connection}, @var{command}, @var{copydata}, @dots{})\n\ Sends the string @var{command}, which should contain one or more SQL commands, over the connection @var{connection} and returns multiple output values, one for each command. For queries (commands potentially returning data), the output will be a structure with fields @code{data} (containing a cell array with the data) and @code{columns} (containing the column headers). For other commands, the output will be the number of affected rows in the database. For each command in @var{command} containing a @code{COPY FROM STDIN}, an additional argument @var{copydata} must be supplied which is either a cell-array with suitable data or a handle for a function which will return parts of this cell-array successively, one for each call, and @code{0} when ready.\n\ \n\ @end deftypefn") { std::string fname ("pq_exec"); octave_value_list retval; if (args.length () < 2 || args.length () > 3 || args(0).type_id () != octave_pq_connection::static_type_id ()) { print_usage (); return retval; } std::string cmd (args(1).string_value ()); if (error_state) { error ("%s: second argument can not be converted to a string", fname.c_str ()); return retval; } const octave_base_value& rep = (args(0).get_rep ()); const octave_pq_connection &oct_pq_conn = dynamic_cast (rep); Cell rettypes; // not implemented here command c (*(oct_pq_conn.get_rep ()), cmd, rettypes, fname); if (c.good ()) { while (true) { octave_value val; val = c.process_single_result (); if (! c.good () || c.all_results_fetched ()) break; else { int l = retval.length (); retval.resize (l + 1); retval (l) = val; } } } return retval; } #endif // code disabled DEFUN_DLD (__pq_exec_params__, args, nargout, "-*- texinfo -*-\n\ undifined internal function, meant to be called by @code{pq_exec_params}") { std::string fname ("__pq_exec_params__"); octave_value retval; int nargs = args.length (); if (nargs < 2 || nargs > 4 || args(0).type_id () != octave_pq_connection::static_type_id ()) { print_usage (); return retval; } std::string cmd; CHECK_ERROR (cmd = args(1).string_value (), retval, "%s: second argument can not be converted to a string", fname.c_str ()); const octave_base_value &rep = args(0).get_rep (); const octave_pq_connection &oct_pq_conn = dynamic_cast (rep); /* printf ("oid map:\n"); for (oct_pq_conv_map_t::iterator it = oct_pq_conn.get_rep ()->conv_map.begin (); it != oct_pq_conn.get_rep ()->conv_map.end (); it++) { printf ("key: %u; ", it->first); print_conv (it->second); } printf ("\n"); printf ("name map:\n"); for (oct_pq_name_conv_map_t::iterator it = oct_pq_conn.get_rep ()->name_conv_map.begin (); it != oct_pq_conn.get_rep ()->name_conv_map.end (); it++) { printf ("key: %s; ", it->first); print_conv (it->second); } printf ("\n"); */ Cell params; octave_scalar_map settings; bool err; if (nargs == 3) { if (args(2).OV_ISCELL ()) { SET_ERR (params = args(2).cell_value (), err); } else { SET_ERR (settings = args(2).scalar_map_value (), err); } if (err) { error ("%s: third argument neither cell-array nor scalar structure", fname.c_str ()); return retval; } } else if (nargs == 4) { CHECK_ERROR (params = args(2).cell_value (), retval, "%s: could not convert third argument to cell-array", fname.c_str ()); CHECK_ERROR (settings = args(3).scalar_map_value (), retval, "%s: could not convert fourth argument to scalar structure", fname.c_str ()); } int nparams = params.numel (); dim_vector pdims = params.dims (); if (pdims.length () > 2 || (pdims(0) > 1 && pdims(1) > 1)) { error ("%s: cell-array of parameters must not be more than one-dimensional", fname.c_str ()); return retval; } // get option settings octave_value_list f_args (3); octave_value_list f_ret; f_args(0) = octave_value (settings); f_args(1) = octave_value ("param_types"); f_args(2) = octave_value (Cell (1, nparams)); CHECK_ERROR (f_ret = OCTAVE__FEVAL ("getdbopts", f_args, 1), retval, "%s: error calling getdbopts", fname.c_str ()); Cell ptypes; CHECK_ERROR (ptypes = f_ret(0).cell_value (), retval, "%s: could not convert param_types to cell", fname.c_str ()); f_args(1) = octave_value ("copy_in_path"); f_args(2) = octave_value (""); CHECK_ERROR (f_ret = OCTAVE__FEVAL ("getdbopts", f_args, 1), retval, "%s: error calling getdbopts", fname.c_str ()); std::string cin_path; CHECK_ERROR (cin_path = f_ret(0).string_value (), retval, "%s: could not convert copy_in_path to string", fname.c_str ()); f_args(1) = octave_value ("copy_out_path"); f_args(2) = octave_value (""); CHECK_ERROR (f_ret = OCTAVE__FEVAL ("getdbopts", f_args, 1), retval, "%s: error calling getdbopts", fname.c_str ()); std::string cout_path; CHECK_ERROR (cout_path = f_ret(0).string_value (), retval, "%s: could not convert copy_out_path to string", fname.c_str ()); f_args(1) = octave_value ("copy_in_data"); f_args(2) = octave_value (Cell ()); CHECK_ERROR (f_ret = OCTAVE__FEVAL ("getdbopts", f_args, 1), retval, "%s: error calling getdbopts", fname.c_str ()); Cell cin_data; CHECK_ERROR (cin_data = f_ret(0).cell_value (), retval, "%s: could not convert copy_in_data to cell", fname.c_str ()); f_args(1) = octave_value ("copy_in_with_oids"); f_args(2) = octave_value (false); CHECK_ERROR (f_ret = OCTAVE__FEVAL ("getdbopts", f_args, 1), retval, "%s: error calling getdbopts", fname.c_str ()); bool cin_with_oids = false; CHECK_ERROR (cin_with_oids = f_ret(0).bool_value (), retval, "%s: could not convert copy_in_with_oids to bool", fname.c_str ()); f_args(1) = octave_value ("copy_in_types"); f_args(2) = octave_value (Cell ()); CHECK_ERROR (f_ret = OCTAVE__FEVAL ("getdbopts", f_args, 1), retval, "%s: error calling getdbopts", fname.c_str ()); Cell cin_types; CHECK_ERROR (cin_types = f_ret(0).cell_value (), retval, "%s: could not convert copy_in_types to cell", fname.c_str ()); f_args(1) = octave_value ("copy_in_from_variable"); f_args(2) = octave_value (false); CHECK_ERROR (f_ret = OCTAVE__FEVAL ("getdbopts", f_args, 1), retval, "%s: error calling getdbopts", fname.c_str ()); bool cin_from_variable = false; CHECK_ERROR (cin_from_variable = f_ret(0).bool_value (), retval, "%s: could not convert copy_in_from_variable to bool", fname.c_str ()); // check option settings if (ptypes.numel () != nparams) { error ("%s: if given, cell-array of parameter types must have same length as cell-array of parameters", fname.c_str ()); return retval; } dim_vector cind_dv = cin_data.dims (); if (cind_dv.length () > 2) { error ("%s: copy-in data must not be more than two-dimensional", fname.c_str ()); return retval; } if (cin_types.OV_ISEMPTY ()) cin_types.resize (dim_vector (1, cind_dv(1))); if (cin_types.numel () != cind_dv(1)) { error ("%s: copy_in_types has wrong number of elements", fname.c_str ()); return retval; } // Cell rtypes; command c (*(oct_pq_conn.get_rep ()), cmd, params, ptypes, rtypes, fname); if (c.good ()) retval = c.process_single_result (cin_path, cout_path, cin_data, cin_types, cin_with_oids, cin_from_variable); if (! c.good ()) error ("%s: error processing result", fname.c_str ()); return retval; } database-2.4.4/src/PaxHeaders.8241/__pq_internal_exit__.cc0000644000000000000000000000013213444726064020211 xustar0030 mtime=1553181748.559424007 30 atime=1553181748.559424007 30 ctime=1553181803.415144792 database-2.4.4/src/__pq_internal_exit__.cc0000644000175000017500000000306713444726064020470 0ustar00olafolaf00000000000000// Copyright (C) 2008-2019 Olaf Till // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include // PKG_ADD: autoload ("__pq_internal_exit__", "pq_interface.oct"); // PKG_DEL: autoload ("__pq_internal_exit__", "pq_interface.oct", "remove"); // This function duplicates __exit__.cc to avoid the dependency on the // package main/general. DEFUN_DLD (__pq_internal_exit__, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} __pq_internal_exit__ (status)\n\ This is a wrapper over the POSIX _exit() system call. Calling this function\n\ will terminate the running process immediately, bypassing normal Octave\n\ terminating sequence. It is suitable to terminate a forked process. It\n\ should be considered expert-only and not to be used in normal code.\n\ @end deftypefn") { _exit (args.length () > 0 ? args(0).int_value () : 0); } database-2.4.4/src/PaxHeaders.8241/wrap_endian.h0000644000000000000000000000013213444726064016201 xustar0030 mtime=1553181748.674457167 30 atime=1553181799.954646525 30 ctime=1553181803.415144792 database-2.4.4/src/wrap_endian.h0000644000175000017500000000257713444726064016465 0ustar00olafolaf00000000000000/* This file is in the public domain. The Apple-specific include and defines were taken from a public domain file at this site: https://gist.github.com/yinyin/2027912 */ #ifndef __OCT_PQ_WRAP_ENDIAN__ #define __OCT_PQ_WRAP_ENDIAN__ #ifdef __APPLE__ #include #define htobe16(x) OSSwapHostToBigInt16(x) #define htole16(x) OSSwapHostToLittleInt16(x) #define be16toh(x) OSSwapBigToHostInt16(x) #define le16toh(x) OSSwapLittleToHostInt16(x) #define htobe32(x) OSSwapHostToBigInt32(x) #define htole32(x) OSSwapHostToLittleInt32(x) #define be32toh(x) OSSwapBigToHostInt32(x) #define le32toh(x) OSSwapLittleToHostInt32(x) #define htobe64(x) OSSwapHostToBigInt64(x) #define htole64(x) OSSwapHostToLittleInt64(x) #define be64toh(x) OSSwapBigToHostInt64(x) #define le64toh(x) OSSwapLittleToHostInt64(x) #else #ifdef __MINGW32__ #include #define htobe16(x) htons(x) #define htole16(x) (x) #define be16toh(x) ntohs(x) #define le16toh(x) (x) #define htobe32(x) htonl(x) #define htole32(x) (x) #define be32toh(x) ntohl(x) #define le32toh(x) (x) #define htobe64(x) (((uint64_t)htonl((uint32_t)(x>>32)))|(((uint64_t)htonl(x&0xFFFFFFFF))<<32LL)) #define htole64(x) (x) #define be64toh(x) (((uint64_t)ntohl((uint32_t)(x>>32)))|(((uint64_t)ntohl(x&0xFFFFFFFF))<<32LL)) #define le64toh(x) (x) #else #include #endif #endif #endif // __OCT_PQ_WRAP_ENDIAN__ database-2.4.4/src/PaxHeaders.8241/config.h.in0000644000000000000000000000013213444726066015566 xustar0030 mtime=1553181750.238745329 30 atime=1553181799.658587654 30 ctime=1553181803.415144792 database-2.4.4/src/config.h.in0000644000175000017500000000457413444726066016051 0ustar00olafolaf00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ #include "undef-ah-octave.h" /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `pq' library (-lpq). */ #undef HAVE_LIBPQ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define as 1 if liboctinterp is old enough to provide error_state. */ #undef HAVE_OCTAVE_ERROR_STATE /* Define to 1 if you have the header file. */ #undef HAVE_OCTAVE_INTERPRETER_H /* Define as 1 if liboctinterp has 'verror (octave(_|::)execution_exception&, const char *, va_list)'. */ #undef HAVE_OCTAVE_VERROR_ARG_EXC /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* macro for alternative Octave symbols */ #undef OCTAVE__EXECUTION_EXCEPTION /* macro for alternative Octave symbols */ #undef OCTAVE__FEVAL /* macro for alternative Octave symbols */ #undef OCTAVE__MACH_INFO /* macro for alternative Octave symbols */ #undef OCTAVE__VFORMAT /* macro for alternative Octave symbols */ #undef OV_ISCELL /* macro for alternative Octave symbols */ #undef OV_ISEMPTY /* macro for alternative Octave symbols */ #undef OV_ISFLOAT /* macro for alternative Octave symbols */ #undef OV_ISINTEGER /* macro for alternative Octave symbols */ #undef OV_ISREAL /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS #include "oct-alt-includes.h" database-2.4.4/src/PaxHeaders.8241/oct-alt-includes.h0000644000000000000000000000013213444726147017063 xustar0030 mtime=1553181799.514559015 30 atime=1553181800.290705842 30 ctime=1553181803.415144792 database-2.4.4/src/oct-alt-includes.h0000644000175000017500000000011213444726147017326 0ustar00olafolaf00000000000000/* generated by configure */ #include database-2.4.4/src/PaxHeaders.8241/pq_connection.cc0000644000000000000000000000013213444726064016707 xustar0030 mtime=1553181748.638757221 30 atime=1553181748.638757221 30 ctime=1553181803.415144792 database-2.4.4/src/pq_connection.cc0000644000175000017500000004106713444726064017170 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include "pq_connection.h" #include "command.h" #include "error-helpers.h" DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_pq_connection, "PGconn", "PGconn") std::string &pq_basetype_prefix (void) { static std::string prefix ("pg_catalog."); return prefix; } const int pq_bpl = pq_basetype_prefix ().size (); static bool map_str_cmp (const char *c1, const char *c2) { if (strcmp (c1, c2) < 0) return true; else return false; } static bool map_string_cmp (const std::string &s1, const std::string &s2) { if (s1.compare (s2) < 0) return true; else return false; } octave_pq_connection_rep::octave_pq_connection_rep (std::string &arg) : conv_map (), name_conv_map (&map_str_cmp), conn (NULL) { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; conn = PQconnectdb (arg.c_str ()); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (! conn || PQstatus (conn) == CONNECTION_BAD) { if (conn) { _p_error ("%s", PQerrorMessage (conn)); PGconn *t_conn = conn; conn = NULL; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; PQfinish (t_conn); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } _p_error ("PQ connection attempt failed"); } else { // init name converter-map (kind of "bootstrapping") for (int i = 0; i < OCT_PQ_NUM_CONVERTERS; i++) { name_conv_map[conv_ptrs[i]->name.c_str ()] = conv_ptrs[i]; // unqualified name, may be replaced later with user-defined type name_conv_map[conv_ptrs[i]->name.c_str () + pq_bpl] = conv_ptrs[i]; } if (octave_pq_fill_base_types () || octave_pq_get_composite_types () || octave_pq_get_enum_types ()) { PGconn *t_conn = conn; conn = NULL; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; PQfinish (t_conn); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; _p_error ("could not read types"); } else { if (strcmp (PQparameterStatus (conn, "integer_datetimes"), "on")) integer_datetimes = false; else integer_datetimes = true; } } } octave_pq_connection_rep::~octave_pq_connection_rep (void) { if (conn) { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; PQfinish (conn); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; octave_pq_delete_non_constant_types (); } } void octave_pq_connection_rep::octave_pq_close (void) { if (conn) { PGconn *t_conn = conn; conn = NULL; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; PQfinish (t_conn); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; octave_pq_delete_non_constant_types (); } else // deliberately left the 'error' call here, since // 'octave_pq_close()' is only called by 'pq_close' immediately // before returning error ("PGconn object not open"); } void octave_pq_connection_rep::octave_pq_delete_non_constant_types (void) { // In the first map, allocated types are usually referenced twice // (by oid and aoid). Yet we need no refcount as long as we go // through the name map as the last, since there (the same) types // are only referenced once. std::vector t_it_v; for (oct_pq_conv_map_t::iterator it = conv_map.begin (); it != conv_map.end (); it++) if (it->second->is_not_constant) t_it_v.push_back (it); for (std::vector::iterator it = t_it_v.begin (); it != t_it_v.end (); it++) conv_map.erase (*it); std::vector t_name_it_v; for (oct_pq_name_conv_map_t::iterator it = name_conv_map.begin (); it != name_conv_map.end (); it++) { oct_pq_conv_t *conv = it->second; if (conv->is_not_constant) { t_name_it_v.push_back (it); delete conv; } } for (std::vector::iterator it = t_name_it_v.begin (); it != t_name_it_v.end (); it++) name_conv_map.erase (*it); } int octave_pq_connection_rep::octave_pq_fill_base_types (void) { Cell p (0, 0), pt (0, 0), rt (3, 1); rt(0) = octave_value ("oid"); rt(1) = octave_value ("name"); rt(2) = octave_value ("oid"); std::string cmd ("select oid, typname, typarray from pg_type where (typtype = 'b' AND typarray != 0) OR typname = 'record' OR typname = 'unknown';"), caller ("octave_pq_fill_base_types"); command c (*this, cmd, p, pt, rt, caller); if (! c.good ()) { _p_error ("octave_pq_fill_base_types: could not read pg_type"); return 1; } octave_value res = c.process_single_result (); if (! c.good ()) return 1; Cell tpls; bool err; SET_ERR (tpls = res.scalar_map_value ().contents ("data").cell_value (), err); if (err) { _p_error ("octave_pq_fill_base_types: could not convert result data to cell"); return 1; } // make a temporary map of server base types (cell row numbers) for searching typedef std::map bt_map_t; bt_map_t bt_map (&map_string_cmp); for (int i = 0; i < tpls.rows (); i++) { SET_ERR (bt_map[tpls(i, 1).string_value ()] = i, err); if (err) break; } if (err) { _p_error ("octave_pq_fill_base_types: could not read returned result"); return 1; } for (int i = 0; i < OCT_PQ_NUM_CONVERTERS; i++) { bt_map_t::iterator bt_it; if ((bt_it = bt_map.find (conv_ptrs[i]->name.c_str () + pq_bpl)) == bt_map.end ()) { _p_error ("octave_pq_fill_base_types: type %s not found in pg_type", conv_ptrs[i]->name.c_str () + pq_bpl); return 1; } // fill in oid and aoid into static records of converters SET_ERR (conv_ptrs[i]->oid = tpls(bt_it->second, 0).int_value (), err); if (! err) { SET_ERR (conv_ptrs[i]->aoid = tpls(bt_it->second, 2).int_value (), err); } if (err) break; // fill in map of converters over oid with oid and, if not zero, // also with aoid conv_map[conv_ptrs[i]->oid] = conv_ptrs[i]; if (conv_ptrs[i]->aoid != 0) conv_map[conv_ptrs[i]->aoid] = conv_ptrs[i]; } if (err) { _p_error ("octave_pq_fill_base_types: could not read returned result"); return 1; } return 0; } int octave_pq_connection_rep::octave_pq_get_composite_types (void) { Cell p, pt, rt; std::string cmd ("select pg_type.oid, pg_type.typname, pg_type.typarray, pg_namespace.nspname, pg_type_is_visible(pg_type.oid) as visible, array_agg(pg_attribute.atttypid), array_agg(pg_attribute.attnum) from (pg_type join pg_namespace on pg_type.typnamespace = pg_namespace.oid) join pg_attribute on pg_type.typrelid = pg_attribute.attrelid where pg_type.typtype = 'c' and pg_attribute.attnum > 0 group by pg_type.oid, pg_type.typname, pg_type.typarray, pg_type.typrelid, pg_namespace.nspname, visible;"), caller ("octave_pq_get_composite_types"); command c (*this, cmd, p, pt, rt, caller); if (! c.good ()) { _p_error ("octave_pq_get_composite_types: could not read pg_type"); return 1; } octave_value res = c.process_single_result (); if (! c.good ()) return 1; Cell tpls; bool err; SET_ERR (tpls = res.scalar_map_value ().contents ("data").cell_value (), err) if (err) { _p_error ("octave_pq_get_composite_types: could not convert result data to cell"); return 1; } for (int i = 0; i < tpls.rows (); i++) { Oid oid; SET_ERR (oid = tpls(i, 0).uint_value (), err); Oid aoid; if (! err) { SET_ERR (aoid = tpls(i, 2).uint_value (), err); } std::string name; if (! err) { SET_ERR (name = tpls(i, 1).string_value (), err); } std::string nspace; if (! err) { SET_ERR (nspace = tpls(i, 3).string_value (), err); } bool visible = false; if (! err) { SET_ERR (visible = tpls(i, 4).bool_value (), err); } Cell r_el_oids; if (! err) { SET_ERR (r_el_oids = tpls(i, 5).scalar_map_value () .contents ("data").cell_value (), err); } Cell r_el_pos; if (! err) { SET_ERR (r_el_pos = tpls(i, 6).scalar_map_value () .contents ("data").cell_value (), err); } if (err) { _p_error ("octave_pq_get_composite_types: could not read returned result"); return 1; } octave_idx_type nel = r_el_oids.numel (); if (nel != r_el_pos.numel ()) { _p_error ("octave_pq_get_composite_types: internal error, inconsistent content of pg_attribute?"); return 1; } oct_pq_el_oids_t el_oids; el_oids.resize (nel); oct_pq_conv_cache_t conv_cache; conv_cache.resize (nel); for (octave_idx_type i = 0; i < nel; i++) { octave_idx_type pos; // "column" number (attnum) is one-based, so subtract 1 SET_ERR (pos = r_el_pos(i).idx_type_value () - 1, err); if (! err) { if (pos >= nel) { _p_error ("octave_pq_get_composite_types: internal error (?system catalog erroneous?): column position %i greater than ncols %i for type %s, namespace %s", pos, nel, name.c_str (), nspace.c_str ()); return 1; } SET_ERR (el_oids[pos] = r_el_oids(i).uint_value (), err); conv_cache[pos] = NULL; } if (err) { _p_error ("octave_pq_get_composite_types: could not fill in element oids."); return 1; } } // must be allocated and filled before creating the name map // entry, to get a remaining location for the c-string used as // key oct_pq_conv_t *t_conv = new oct_pq_conv_t; t_conv->oid = oid; t_conv->aoid = aoid; t_conv->el_oids = el_oids; t_conv->conv_cache = conv_cache; t_conv->is_composite = true; t_conv->is_enum = false; t_conv->is_not_constant = true; t_conv->name = nspace.append (".").append (name); t_conv->to_octave_str = NULL; t_conv->to_octave_bin = NULL; t_conv->from_octave_str = NULL; t_conv->from_octave_bin = NULL; oct_pq_conv_t *&by_oid = conv_map[oid], *&by_name = name_conv_map[t_conv->name.c_str ()]; if (by_oid || by_name) { _p_error ("octave_pq_get_composite_types: internal error, key already in typemap (by_oid: %u/%li, by name: %s/%li)", oid, by_oid, t_conv->name.c_str (), by_name); if (! by_oid) conv_map.erase (oid); if (! by_name) name_conv_map.erase (t_conv->name.c_str ()); delete t_conv; return 1; } by_oid = by_name = t_conv; oct_pq_conv_t *t_conv_v = NULL; // silence inadequate warning by // initializing it here if (visible) { t_conv_v = new oct_pq_conv_t (*t_conv); t_conv_v->el_oids = el_oids; t_conv_v->conv_cache = conv_cache; t_conv_v->name = name; name_conv_map[t_conv_v->name.c_str ()] = t_conv_v;; } if (aoid) { oct_pq_conv_t *&by_aoid = conv_map[aoid]; if (by_aoid) { _p_error ("octave_pq_get_composite_types: internal error, aoid key %u already in typemap", aoid); conv_map.erase (oid); name_conv_map.erase (t_conv->name.c_str ()); delete t_conv; if (visible) { name_conv_map.erase (t_conv_v->name.c_str ()); delete t_conv_v; } return 1; } by_aoid = by_oid; } } return 0; } int octave_pq_connection_rep::octave_pq_get_enum_types (void) { Cell p, pt, rt; std::string cmd ("select pg_type.oid, pg_type.typname, pg_type.typarray, pg_namespace.nspname, pg_type_is_visible(pg_type.oid) from pg_type join pg_namespace on pg_type.typnamespace = pg_namespace.oid where pg_type.typtype = 'e';"), caller ("octave_pq_get_enum_types"); command c (*this, cmd, p, pt, rt, caller); if (! c.good ()) { _p_error ("octave_pq_get_enum_types: could not read pg_type"); return 1; } octave_value res = c.process_single_result (); if (! c.good ()) return 1; Cell tpls; bool err; SET_ERR (tpls = res.scalar_map_value ().contents ("data").cell_value (), err); if (err) { _p_error ("octave_pq_get_enum_types: could not convert result data to cell"); return 1; } for (int i = 0; i < tpls.rows (); i++) { Oid oid; SET_ERR (oid = tpls(i, 0).uint_value (), err); Oid aoid; if (! err) { SET_ERR (aoid = tpls(i, 2).uint_value (), err); } std::string name; if (! err) { SET_ERR (name = tpls(i, 1).string_value (), err); } std::string nspace; if (! err) { SET_ERR (nspace = tpls(i, 3).string_value (), err); } bool visible; if (! err) { SET_ERR (visible = tpls(i, 4).bool_value (), err); } if (err) { _p_error ("octave_pq_get_enum_types: could not read returned result"); return 1; } // must be allocated and filled before creating the name map // entry, to get a remaining location for the c-string used as // key oct_pq_conv_t *t_conv = new oct_pq_conv_t; t_conv->oid = oid; t_conv->aoid = aoid; t_conv->el_oids = oct_pq_el_oids_t (); t_conv->conv_cache = oct_pq_conv_cache_t (); t_conv->is_composite = false; t_conv->is_enum = true; t_conv->is_not_constant = true; t_conv->name = nspace.append (".").append (name); t_conv->to_octave_str = &to_octave_str_text; t_conv->to_octave_bin = &to_octave_bin_text; t_conv->from_octave_str = &from_octave_str_text; t_conv->from_octave_bin = &from_octave_bin_text; // we trust there is always an array type in the table oct_pq_conv_t *&by_oid = conv_map[oid], *&by_aoid = conv_map[aoid], *&by_name = name_conv_map[t_conv->name.c_str ()]; if (by_oid || by_aoid || by_name) { _p_error ("octave_pq_get_enum_types: internal error, key already in typemap"); if (! by_oid) conv_map.erase (oid); if (! by_aoid) conv_map.erase (aoid); if (! by_name) name_conv_map.erase (t_conv->name.c_str ()); delete t_conv; return 1; } by_oid = by_aoid = by_name = t_conv; if (visible) { oct_pq_conv_t *t_conv_v = new oct_pq_conv_t (*t_conv); t_conv_v->el_oids = oct_pq_el_oids_t (); t_conv_v->conv_cache = oct_pq_conv_cache_t (); t_conv_v->name = name; name_conv_map[t_conv_v->name.c_str ()] = t_conv_v; } } return 0; } int octave_pq_connection_rep::octave_pq_refresh_types (void) { octave_pq_delete_non_constant_types (); // refresh unqualified base type names, may be replaced later with // user-defined types for (int i = 0; i < OCT_PQ_NUM_CONVERTERS; i++) name_conv_map[conv_ptrs[i]->name.c_str () + pq_bpl] = conv_ptrs[i]; if (octave_pq_get_composite_types () || octave_pq_get_enum_types ()) { PGconn *t_conn = conn; conn = NULL; if (t_conn) { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; PQfinish (t_conn); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; } _p_error ("octave_pq_refresh_types: could not read types"); return 1; } else return 0; } database-2.4.4/src/PaxHeaders.8241/var2bytea.cc0000644000000000000000000000013213444726064015747 xustar0030 mtime=1553181748.650657203 30 atime=1553181801.426891663 30 ctime=1553181803.415144792 database-2.4.4/src/var2bytea.cc0000644000175000017500000000655413444726064016232 0ustar00olafolaf00000000000000/* Copyright (C) 2016-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include #include #include "config.h" DEFUN_DLD (var2bytea, args, nout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} var2bytea (@var{value}, @dots{})\n\ Save input values in uint8 arrays in Octaves binary save format.\n\ \n\ This function returns as many output variables as input variables\n\ are given.\n\ \n\ The function can be used to prepare storage of Octave variable\n\ values as binary strings in a database, if the variables types have\n\ no corresponding SQL type.\n\ Each variable type which can be correctly saved and loaded with\n\ Octaves @code{save} and @code{load} functions is acceptable.\n\ The variable value can be restored with the function\n\ @code{bytea2var}.\n\ \n\ Note that the inputs are not variable names, but values.\n\ No variable names are saved.\n\ Loading the uint8 array with @code{load} (possibly after dumping\n\ it to a file) will not work.\n\ \n\ Example: to convert the first and third column of a cell-array @code{c},\n\ @code{[c@{:, [1, 3]@}] = var2bytea (c@{:, [1, 3]@});}\n\ can be used.\n\ \n\ @seealso{bytea2var}\n\ @end deftypefn") { std::string fname ("var2bytea"); octave_idx_type nargs = args.length (); octave_idx_type nvars = nout < nargs ? nout : nargs; octave_value_list retval (nvars); for (octave_idx_type i = 0; i < nvars; i++) { std::ostringstream os; /* slightly changed from load-save.cc (write_header(,LS_BINARY)) to reduce storage size */ os << (OCTAVE__MACH_INFO::words_big_endian () ? "1B" : "1L"); OCTAVE__MACH_INFO::float_format flt_fmt = OCTAVE__MACH_INFO::native_float_format (); char tmp = static_cast (float_format_to_mopt_digit (flt_fmt)); os.write (&tmp, 1); /* Much here is cut-and-pasted from ls-oct-binary.cc (save_binary_data()) in Octave. */ // Write the string corresponding to the octave_value type. std::string typ = args(i).type_name (); int32_t len = typ.length (); os.write (reinterpret_cast (&len), 4); const char *btmp = typ.data (); os.write (btmp, len); // The octave_value of args(i) is const. Make a copy... octave_value val = args(i); // Call specific save function bool save_as_floats = false; if (! val.save_binary (os, save_as_floats) || ! os) { error ("%s: could not save variable %li", fname.c_str (), i + 1); return retval; } std::string s (os.str ()); uint8NDArray m (dim_vector (s.length (), 1)); memcpy (m.fortran_vec (), s.data (), s.length ()); retval(i) = octave_value (m); } return retval; } database-2.4.4/src/PaxHeaders.8241/command.h0000644000000000000000000000013213444726064015330 xustar0030 mtime=1553181748.595123954 30 atime=1553181800.290705842 30 ctime=1553181803.415144792 database-2.4.4/src/command.h0000644000175000017500000000636413444726064015612 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #ifndef __OCT_PQ_COMMAND__ #define __OCT_PQ_COMMAND__ #include #include #include #include "pq_connection.h" #include "error-helpers.h" class command { public: // This constructor is currently not used and probably broken. command (octave_pq_connection_rep &connection, std::string &cmd, Cell &rtypes, std::string &who); command (octave_pq_connection_rep &connection, std::string &cmd, Cell ¶ms, Cell &ptypes, Cell &rtypes, std::string &who); ~command (void) { if (res) PQclear (res); if (! all_fetched) { while ((res = PQgetResult (cptr))) PQclear (res); } } typedef int (*to_octave_array_fp_t) (const octave_pq_connection_rep &, const char *, octave_value &, int, oct_pq_conv_t *); typedef int (*to_octave_composite_fp_t) (const octave_pq_connection_rep &, const char *, octave_value &, int, oct_pq_conv_t *); int all_results_fetched (void) { return all_fetched; } octave_value process_single_result (void) { Cell c; // inlining should prevent the additional copy return process_single_result ("", "", c, c, false, false); } octave_value process_single_result (const std::string &infile, const std::string &outfile, const Cell &cin_data, const Cell &cin_types, bool cin_with_oids, bool cin_from_variable); int good (void) {return valid;} private: octave_map get_elements_typeinfo (oct_pq_conv_t *conv, bool &err); void check_first_result (void) { if (! res) { valid = 0; _p_error ("%s: could not execute command: %s", caller.c_str (), PQerrorMessage (cptr)); } else if ((state = PQresultStatus (res)) == PGRES_EMPTY_QUERY) { valid = 0; _p_error ("%s: empty command", caller.c_str ()); } } octave_value command_ok_handler (void) { char *c = PQcmdTuples (res); return octave_value (atoi (c)); } octave_value tuples_ok_handler (void); octave_value copy_out_handler (const std::string &); octave_value copy_in_handler (const std::string &, const Cell &, const Cell &, bool, bool); PGresult *res; int all_fetched; int valid; ExecStatusType state; octave_pq_connection_rep &conn; PGconn *cptr; Cell &rettypes; std::string &caller; }; #endif // __OCT_PQ_COMMAND__ database-2.4.4/src/PaxHeaders.8241/undef-ah-octave.h0000644000000000000000000000013213444726064016660 xustar0030 mtime=1553181748.646690543 30 atime=1553181800.290705842 30 ctime=1553181803.415144792 database-2.4.4/src/undef-ah-octave.h0000644000175000017500000000070613444726064017134 0ustar00olafolaf00000000000000/* To be included at the top of config.h (by autoheader). Avoid warnings for redefining AH-generated preprocessor symbols of Octave. */ #ifdef PACKAGE_BUGREPORT #undef PACKAGE_BUGREPORT #endif #ifdef PACKAGE_NAME #undef PACKAGE_NAME #endif #ifdef PACKAGE_STRING #undef PACKAGE_STRING #endif #ifdef PACKAGE_TARNAME #undef PACKAGE_TARNAME #endif #ifdef PACKAGE_URL #undef PACKAGE_URL #endif #ifdef PACKAGE_VERSION #undef PACKAGE_VERSION #endif database-2.4.4/src/PaxHeaders.8241/pq_update_types.cc0000644000000000000000000000013213444726064017256 xustar0030 mtime=1553181748.646690543 30 atime=1553181800.394723805 30 ctime=1553181803.415144792 database-2.4.4/src/pq_update_types.cc0000644000175000017500000000345413444726064017535 0ustar00olafolaf00000000000000/* Copyright (C) 2013-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include "command.h" // PKG_ADD: autoload ("pq_update_types", "pq_interface.oct"); // PKG_DEL: autoload ("pq_update_types", "pq_interface.oct", "remove"); DEFUN_DLD (pq_update_types, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} pq_update_types (@var{connection})\n\ Updates information on existing postgresql types for @var{connection}. Use this before @code{pq_exec_params} if types were created or dropped while the connection was already established or if the schema search path changed. A newly created connection will automatically retrieve this information at connection time.\n\ \n\ @end deftypefn") { std::string fname ("pq_update_types"); octave_value_list retval; if (args.length () != 1 || args(0).type_id () != octave_pq_connection::static_type_id ()) { print_usage (); return retval; } const octave_base_value& rep = (args(0).get_rep ()); const octave_pq_connection &oct_pq_conn = dynamic_cast (rep); if (oct_pq_conn.get_rep ()->octave_pq_refresh_types ()) error ("%s failed", fname.c_str ()); return retval; } database-2.4.4/src/PaxHeaders.8241/pkglock.cc0000644000000000000000000000013213444726064015502 xustar0030 mtime=1553181748.638757221 30 atime=1553181748.634790561 30 ctime=1553181803.415144792 database-2.4.4/src/pkglock.cc0000644000175000017500000000320613444726064015754 0ustar00olafolaf00000000000000// Copyright (C) 2019 John Donoghue // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 3 of the License, or (at your option) any later // version. // // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // this program; if not, see . // slightly modified by Olaf Till // to have Octaves config.h included before config.h of 'database' #include #include "config.h" #ifdef HAVE_OCTAVE_INTERPRETER_H #include #endif // PKG_ADD: autoload ("__database_pkg_lock__", "pq_interface.oct"); // PKG_ADD: __database_pkg_lock__(1); // PKG_DEL: __database_pkg_lock__(0); // PKG_DEL: autoload ("__database_pkg_lock__", "pq_interface.oct", "remove"); #ifdef DEFMETHOD_DLD DEFMETHOD_DLD (__database_pkg_lock__, interp, args, , "internal function") { octave_value retval; if (args.length () >= 1) { if (args(0).int_value () == 1) interp.mlock(); else if (args(0).int_value () == 0 && interp.mislocked("__database_pkg_lock__")) interp.munlock("__database_pkg_lock__"); } return retval; } #else DEFUN_DLD(__database_pkg_lock__, args, , "internal function") { octave_value retval; return retval; } #endif database-2.4.4/src/PaxHeaders.8241/command.cc0000644000000000000000000000013213444726064015466 xustar0030 mtime=1553181748.591157293 30 atime=1553181748.591157293 30 ctime=1553181803.415144792 database-2.4.4/src/command.cc0000644000175000017500000006240713444726064015750 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include #include #include #include #include #include "command.h" #include "converters.h" #include "error-helpers.h" #define COPY_HEADER_SIZE 19 #define COUT_RESIZE_STEP 1000 // resize result only after this number of rows // This constructor is currently not used and probably broken. command::command (octave_pq_connection_rep &connection, std::string &cmd, Cell &rtypes, std::string &who) : res (NULL), all_fetched (0), valid (1), conn (connection), rettypes (rtypes), caller (who) { if (! (cptr = conn.octave_pq_get_conn ())) { valid = 0; _p_error ("%s: connection not open", caller.c_str ()); } if (! PQsendQuery (cptr, cmd.c_str ())) { valid = 0; _p_error ("%s: could not dispatch command: %s", caller.c_str (), PQerrorMessage (cptr)); } else { res = PQgetResult (cptr); check_first_result (); } } command::command (octave_pq_connection_rep &connection, std::string &cmd, Cell ¶ms, Cell &ptypes, Cell &rtypes, std::string &who) : res (NULL), all_fetched (1), valid (1), conn (connection), rettypes (rtypes), caller (who) { if (! (cptr = conn.octave_pq_get_conn ())) { valid = 0; _p_error ("%s: connection not open", caller.c_str ()); } int npars = params.numel (); char *vals [npars]; std::vector valsvec; valsvec.resize (npars); int pl [npars]; int pf [npars]; Oid oids [npars]; for (int i = 0; i < npars; i++) { pf[i] = 1; // means binary format if (params(i).is_real_scalar () && params(i).isna ().bool_value ()) { vals[i] = NULL; oids[i] = 0; } else { pq_oct_type_t oct_type; oct_pq_conv_t *conv; if (ptypes(i).OV_ISEMPTY ()) { oct_type = simple; if (! (conv = pgtype_from_octtype (conn, params(i)))) { valid = 0; break; } // array not possible here oids[i] = conv->oid; } else { bool err; std::string s; SET_ERR (s = ptypes(i).string_value (), err); if (err) { valid = 0; _p_error ("%s: parameter type specification no string", caller.c_str ()); break; } if (! (conv = pgtype_from_spec (conn, s, oct_type))) { valid = 0; break; } if (oct_type == array) oids[i] = conv->aoid; else oids[i] = conv->oid; } switch (oct_type) { case simple: if (conv->from_octave_bin (conn, params(i), valsvec[i])) valid = 0; break; case array: if (from_octave_bin_array (conn, params(i), valsvec[i], conv)) valid = 0; break; case composite: if (from_octave_bin_composite (conn, params(i), valsvec[i], conv)) valid = 0; break; default: // should not get here valid = 0; _p_error ("%s: internal error, undefined type identifier", caller.c_str ()); } if (! valid) break; vals[i] = &(valsvec[i].front ()); pl[i] = valsvec[i].size (); } } if (valid) { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; res = PQexecParams (cptr, cmd.c_str (), npars, oids, vals, pl, pf, 1); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; check_first_result (); } } octave_map command::get_elements_typeinfo (oct_pq_conv_t *conv, bool &err) { int nel = conv->el_oids.size (); octave_map ret (dim_vector (1, nel)); Cell types_name (1, nel); Cell types_array (1, nel); Cell types_composite (1, nel); Cell types_enum (1, nel); Cell types_elements (1, nel); for (int i = 0; i < nel; i++) { oct_pq_conv_t *el_conv; pq_oct_type_t oct_type; if (! (el_conv = pgtype_from_spec (conn, conv->el_oids[i], conv->conv_cache[i], oct_type))) { err = true; return ret; } types_name(i) = octave_value (el_conv->name); types_array(i) = octave_value (oct_type == array); types_enum(i) = octave_value (el_conv->is_enum); types_composite(i) = octave_value (el_conv->is_composite); if (el_conv->is_composite) { bool rec_err = false; types_elements(i) = octave_value (get_elements_typeinfo (el_conv, rec_err)); if (rec_err) { err = true; return ret; } } } ret.assign ("name", types_name); ret.assign ("is_array", types_array); ret.assign ("is_composite", types_composite); ret.assign ("is_enum", types_enum); ret.assign ("elements", types_elements); return ret; } octave_value command::process_single_result (const std::string &infile, const std::string &outfile, const Cell &cdata, const Cell &ctypes, bool coids, bool cin_var) { octave_value retval; // first result is already fetched if (! res && (res = PQgetResult (cptr))) state = PQresultStatus (res); if (! res) all_fetched = 1; else { switch (state) { case PGRES_BAD_RESPONSE: valid = 0; _p_error ("%s: server response not understood", caller.c_str ()); break; case PGRES_FATAL_ERROR: valid = 0; _p_error ("%s: fatal error: %s", caller.c_str (), PQresultErrorMessage (res)); break; case PGRES_COMMAND_OK: retval = command_ok_handler (); break; case PGRES_TUPLES_OK: retval = tuples_ok_handler (); break; case PGRES_COPY_OUT: retval = copy_out_handler (outfile); break; case PGRES_COPY_IN: retval = copy_in_handler (infile, cdata, ctypes, coids, cin_var); break; case PGRES_NONFATAL_ERROR: break; default: valid = 0; _p_error ("internal error, unexpected server response"); } if (res) // could have been changed by a handler { PQclear (res); res = NULL; } } return retval; } octave_value command::tuples_ok_handler (void) { octave_map ret; int nt = PQntuples (res); int nf = PQnfields (res); Cell data (nt, nf); Cell columns (1, nf); Cell types_name (1, nf); Cell types_array (1, nf); Cell types_composite (1, nf); Cell types_enum (1, nf); Cell types_elements (1, nf); octave_map types (dim_vector (1, nf)); bool rtypes_given; int l = rettypes.numel (); if (l > 0) { if (l != nf) { valid = 0; _p_error ("%s: wrong number of given returned types", caller.c_str ()); return octave_value (); } rtypes_given = true; } else rtypes_given = false; for (int j = 0; j < nf; j++) // j is column { columns(j) = octave_value (PQfname (res, j)); int f = PQfformat (res, j); oct_pq_to_octave_fp_t simple_type_to_octave; to_octave_array_fp_t array_to_octave; to_octave_composite_fp_t composite_to_octave; oct_pq_conv_t *conv = NULL; // silence inadequate warning by // initializing it here pq_oct_type_t oct_type; if (rtypes_given) // for internal reading of system tables { std::string type; bool err; SET_ERR (type = rettypes(j).string_value (), err); if (err) { valid = 0; _p_error ("%s: could not convert given type to string", caller.c_str ()); break; } else if (! (conv = pgtype_from_spec (conn, type, oct_type))) { valid = 0; break; } } else if (! (conv = pgtype_from_spec (conn, PQftype (res, j), oct_type))) { valid = 0; break; } if (f) { array_to_octave = &to_octave_bin_array; composite_to_octave = &to_octave_bin_composite; // will be NULL for non-simple converters simple_type_to_octave = conv->to_octave_bin; } else { array_to_octave = &to_octave_str_array; composite_to_octave = &to_octave_str_composite; // will be NULL for non-simple converters simple_type_to_octave = conv->to_octave_str; } // prepare type information types_name(j) = octave_value (conv->name); types_array(j) = octave_value (oct_type == array); types_enum(j) = octave_value (conv->is_enum); types_composite(j) = octave_value (conv->is_composite); if (conv->is_composite) { // To implement here: recursively go through the elements // and return respective recursive structures. This has the // side effect that all converters necessary for this query // will be looked up and cached (if they aren't already), so // in the actual conversion of composite types only cache // reads are performed, no map lookups. bool err = false; types_elements(j) = octave_value (get_elements_typeinfo (conv, err)); if (err) { valid = 0; break; } } for (int i = 0; i < nt; i++) // i is row { if (PQgetisnull (res, i, j)) data(i, j) = octave_value (octave_NA); else { char *v = PQgetvalue (res, i, j); int nb = PQgetlength (res, i, j); octave_value ov; switch (oct_type) { case simple: if (simple_type_to_octave (conn, v, ov, nb)) valid = 0; break; case array: if (array_to_octave (conn, v, ov, nb, conv)) valid = 0; break; case composite: if (composite_to_octave (conn, v, ov, nb, conv)) valid = 0; break; default: // should not get here _p_error ("%s: internal error, undefined type identifier", caller.c_str ()); valid = 0; } if (valid) data(i, j) = ov; else break; } } if (! valid) break; } if (! valid) return octave_value (); else { ret.assign ("data", octave_value (data)); ret.assign ("columns", octave_value (columns)); types.setfield ("name", types_name); types.setfield ("is_array", types_array); types.setfield ("is_composite", types_composite); types.setfield ("is_enum", types_enum); types.setfield ("elements", types_elements); ret.assign ("types", octave_value (types)); return octave_value (ret); } } octave_value command::copy_out_handler (const std::string &outfile) { octave_value retval; if (! outfile.empty ()) { // store unchecked output in file std::ofstream ostr (outfile.c_str (), std::ios_base::out); if (ostr.fail ()) { valid = 0; _p_error ("could not open output file %s", outfile.c_str ()); return retval; } char *data; int nb; while ((nb = PQgetCopyData (cptr, &data, 0)) > 0) { if (! (ostr.fail () || ostr.bad ())) { ostr.write (data, nb); if (ostr.bad ()) _p_error ("write to file failed"); } PQfreemem (data); } if (! ostr.bad ()) ostr.close (); if (nb == -2) { valid = 0; _p_error ("server error in copy-out: %s", PQerrorMessage (cptr)); } else { PQclear (res); if ((res = PQgetResult (cptr))) { if ((state = PQresultStatus (res)) == PGRES_FATAL_ERROR) { valid = 0; _p_error ("server error in copy-out: %s", PQerrorMessage (cptr)); } } else { valid = 0; _p_error ("unexpectedly got no result information"); } } } else { valid = 0; _p_error ("no output file given"); } return octave_value (std::string ("copy out")); } octave_value command::copy_in_handler (const std::string &infile, const Cell &data, const Cell &cin_types, bool oids, bool var) { octave_value retval; #define OCT_PQ_READSIZE 4096 char buff [OCT_PQ_READSIZE]; if (! var) { // read unchecked input from file if (infile.empty ()) { valid = 0; _p_error ("no input file given"); return retval; } std::ifstream istr (infile.c_str (), std::ios_base::in); if (istr.fail ()) { _p_error ("could not open input file %s", infile.c_str ()); PQputCopyEnd (cptr, "could not open input file"); _p_error ("server error: %s", PQerrorMessage (cptr)); valid = 0; return retval; } do { istr.read (buff, OCT_PQ_READSIZE); if (istr.bad ()) { valid = 0; _p_error ("could not read file %s", infile.c_str ()); break; } else { int nb; if ((nb = istr.gcount ()) > 0) if (PQputCopyData (cptr, buff, nb) == -1) { valid = 0; _p_error ("%s", PQerrorMessage (cptr)); break; } } } while (! istr.eof ()); istr.close (); if (! valid) { PQputCopyEnd (cptr, "copy-in interrupted"); _p_error ("%s", PQerrorMessage (cptr)); } else { if (PQputCopyEnd (cptr, NULL) == -1) { valid = 0; _p_error ("%s", PQerrorMessage (cptr)); } else { PQclear (res); if ((res = PQgetResult (cptr))) { if ((state = PQresultStatus (res)) == PGRES_FATAL_ERROR) { valid = 0; _p_error ("server error in copy-in: %s", PQerrorMessage (cptr)); } } else { valid = 0; _p_error ("unexpectedly got no result information"); } } } } else { // copy in from octave variable dim_vector dv = data.dims (); octave_idx_type r = dv(0); octave_idx_type c = dv(1); octave_idx_type nf = PQnfields (res); if (c != nf + oids) { valid = 0; _p_error ("variable for copy-in has %i columns, but should have %i", c, nf + oids); PQputCopyEnd (cptr, "variable for copy-in has wrong number of columns"); } else if (! PQbinaryTuples (res)) { valid = 0; _p_error ("copy-in from variable must use binary mode"); PQputCopyEnd (cptr, "copy-in from variable must use binary mode"); } else { for (octave_idx_type j = 0; j < nf; j++) if (! PQfformat (res, j)) { valid = 0; _p_error ("copy-in from variable must use binary mode in all columns"); PQputCopyEnd (cptr, "copy-in from variable must use binary mode in all columns"); break; } } if (! valid) { _p_error ("server error: %s", PQerrorMessage (cptr)); return retval; } char header [COPY_HEADER_SIZE]; memset (header, 0, COPY_HEADER_SIZE); strcpy (header, "PGCOPY\n\377\r\n\0"); uint32_t tpu32 = htobe32 (uint32_t (oids) << 16); memcpy (&header[11], &tpu32, 4); char trailer [2]; int16_t tp16 = htobe16 (int16_t (-1)); memcpy (&trailer, &tp16, 2); if (PQputCopyData (cptr, header, COPY_HEADER_SIZE) == -1) { PQputCopyEnd (cptr, "could not send header"); valid = 0; _p_error ("server error: %s", PQerrorMessage (cptr)); } else { oct_pq_conv_t *convs [c]; memset (convs, 0, sizeof (convs)); pq_oct_type_t oct_types [c]; for (octave_idx_type i = 0; i < r; i++) // i is row { int16_t fc = htobe16 (int16_t (nf)); if (PQputCopyData (cptr, (char *) &fc, 2) == -1) { _p_error ("%s", PQerrorMessage (cptr)); PQputCopyEnd (cptr, "error sending field count"); _p_error ("server error: %s", PQerrorMessage (cptr)); valid = 0; break; } // j is column of argument data for (octave_idx_type j = 0; j < c; j++) { if (data(i, j).is_real_scalar () && data(i, j).isna ().bool_value ()) { int32_t t = htobe32 (int32_t (-1)); if (PQputCopyData (cptr, (char *) &t, 4) == -1) { valid = 0; _p_error ("could not send NULL in copy-in"); break; } } else { if (! convs [j]) { if ((j == 0) && oids) { std::string t ("oid"); if (! (convs[0] = pgtype_from_spec (conn, t, oct_types[0]))) { valid = 0; _p_error ("could not get converter for oid in copy-in"); break; } } else { if (cin_types(j).OV_ISEMPTY ()) { oct_types[j] = simple; if (! (convs[j] = pgtype_from_octtype (conn, data(i, j)))) { valid = 0; _p_error ("could not determine type in column %i for copy-in", j); break; } } else { bool err; std::string s; SET_ERR (s = cin_types(j).string_value (), err); if (err) { valid = 0; _p_error ("column type specification no string"); break; } if (! (convs[j] = pgtype_from_spec (conn, s, oct_types[j]))) { valid = 0; _p_error ("invalid column type specification"); break; } } } } // ! convs [j] oct_pq_dynvec_t val; bool conversion_failed = false; switch (oct_types[j]) { case simple: if (convs[j]->from_octave_bin (conn, data(i, j), val)) conversion_failed = true; break; case array: if (from_octave_bin_array (conn, data(i, j), val, convs[j])) conversion_failed = true; break; case composite: if (from_octave_bin_composite (conn, data(i, j), val, convs[j])) conversion_failed = true; break; default: // should not get here _p_error ("internal error, undefined type identifier"); conversion_failed = true; } if (conversion_failed) { valid = 0; error ("could not convert data(%li, %li) for copy-in", i, j); } else { uint32_t t = htobe32 (uint32_t (val.size ())); if (PQputCopyData (cptr, (char *) &t, 4) == -1) { valid = 0; _p_error ("could not send data length in copy-in"); } else if (PQputCopyData (cptr, &(val.front ()), val.size ()) == -1) { valid = 0; _p_error ("could not send copy-in data"); } } if (! valid) break; } } // columns of argument data if (! valid) { PQputCopyEnd (cptr, "error sending copy-in data"); _p_error ("server error: %s", PQerrorMessage (cptr)); break; } } // rows of argument data } if (valid) if (PQputCopyData (cptr, trailer, 2) == -1) { valid = 0; PQputCopyEnd (cptr, "could not send trailer"); _p_error ("%s", PQerrorMessage (cptr)); } if (valid) { if (PQputCopyEnd (cptr, NULL) == -1) { valid = 0; _p_error ("%s", PQerrorMessage (cptr)); } else { PQclear (res); if ((res = PQgetResult (cptr))) { if ((state = PQresultStatus (res)) == PGRES_FATAL_ERROR) { valid = 0; _p_error ("server error in copy-in: %s", PQerrorMessage (cptr)); } } else { valid = 0; _p_error ("unexpectedly got no result information"); } } } } // copy from variable return octave_value (std::string ("copy in")); } database-2.4.4/src/PaxHeaders.8241/pq_lo.cc0000644000000000000000000000013213444726064015162 xustar0030 mtime=1553181748.646690543 30 atime=1553181800.766788057 30 ctime=1553181803.415144792 database-2.4.4/src/pq_lo.cc0000644000175000017500000004167213444726064015445 0ustar00olafolaf00000000000000/* Copyright (C) 2013-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include #include #include #include "command.h" #include "error-helpers.h" #include // PKG_ADD: autoload ("pq_lo_import", "pq_interface.oct"); // PKG_ADD: autoload ("pq_lo_export", "pq_interface.oct"); // PKG_ADD: autoload ("pq_lo_unlink", "pq_interface.oct"); // PKG_DEL: autoload ("pq_lo_import", "pq_interface.oct", "remove"); // PKG_DEL: autoload ("pq_lo_export", "pq_interface.oct", "remove"); // PKG_DEL: autoload ("pq_lo_unlink", "pq_interface.oct", "remove"); #define OCT_PQ_BUFSIZE 1024 // For cleanup handling this is a class. class pipe_to_lo { public: pipe_to_lo (octave_pq_connection_rep &, const char *, bool, std::string &); ~pipe_to_lo (void); bool valid (void) { return oid_valid; } Oid get_oid (void) { return oid; } std::string &msg; private: octave_pq_connection_rep &oct_pq_conn; PGconn *conn; Oid oid; FILE *fp; bool oid_valid; int lod; bool commit; }; pipe_to_lo::pipe_to_lo (octave_pq_connection_rep &a_oct_pq_conn, const char *cmd, bool acommit, std::string &amsg) : msg (amsg), oct_pq_conn (a_oct_pq_conn), conn (a_oct_pq_conn.octave_pq_get_conn ()), oid (0), fp (NULL), oid_valid (false), lod (-1), commit (acommit) { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; oid = lo_creat (conn, INV_WRITE); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (! oid || oid == InvalidOid) { msg = PQerrorMessage (conn); oid = 0; return; } if (! (fp = popen (cmd, "r"))) { msg = "could not create pipe"; return; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; lod = lo_open (conn, oid, INV_WRITE); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (lod == -1) { msg = PQerrorMessage (conn); return; } char buff [OCT_PQ_BUFSIZE]; int nb = 0, pnb = 0; // silence inadequate warnings by initializing // them while (true) { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; nb = fread (buff, 1, OCT_PQ_BUFSIZE, fp); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (! nb) break; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; pnb = lo_write (conn, lod, buff, nb); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (pnb != nb) { msg = PQerrorMessage (conn); break; } } if (nb) return; if (pclose (fp) == -1) _p_error ("error closing pipe"); fp = NULL; if (lo_close (conn, lod)) msg = PQerrorMessage (conn); else oid_valid = true; lod = -1; } pipe_to_lo::~pipe_to_lo (void) { if (lod != -1) { if (lo_close (conn, lod)) _p_error ("%s", PQerrorMessage (conn)); lod = -1; } if (oid && ! oid_valid) { if (lo_unlink (conn, oid) == -1) _p_error ("error unlinking new large object with oid %i", oid); } else oid = 0; if (fp) { if (pclose (fp) == -1) _p_error ("error closing pipe"); fp = NULL; } if (commit) { std::string cmd ("commit;"); Cell params; Cell ptypes (1, 0); Cell rtypes; std::string caller ("pq_lo_import"); command c (oct_pq_conn, cmd, params, ptypes, rtypes, caller); if (c.good ()) c.process_single_result (); if (! c.good ()) _p_error ("%s: could not commit", caller.c_str ()); } } // For cleanup handling this is a class. class lo_to_pipe { public: lo_to_pipe (octave_pq_connection_rep &, Oid, const char *, bool, std::string &); ~lo_to_pipe (void); bool valid (void) { return success; } std::string &msg; private: octave_pq_connection_rep &oct_pq_conn; PGconn *conn; Oid oid; FILE *fp; bool success; int lod; bool commit; }; lo_to_pipe::lo_to_pipe (octave_pq_connection_rep &a_oct_pq_conn, Oid aoid, const char *cmd, bool acommit, std::string &amsg) : msg (amsg), oct_pq_conn (a_oct_pq_conn), conn (a_oct_pq_conn.octave_pq_get_conn ()), oid (aoid), fp (NULL), success (false), lod (-1), commit (acommit) { if (! (fp = popen (cmd, "w"))) { msg = "could not create pipe"; return; } BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; lod = lo_open (conn, oid, INV_READ); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (lod == -1) { msg = PQerrorMessage (conn); return; } char buff [OCT_PQ_BUFSIZE]; int nb = 0, pnb = 0; // silence inadequate warnings by initializing // them while (true) { BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; pnb = lo_read (conn, lod, buff, OCT_PQ_BUFSIZE); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (pnb == -1) { msg = PQerrorMessage (conn); break; } if (! pnb) break; BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; nb = fwrite (buff, 1, pnb, fp); END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE; if (nb != pnb) { msg = "error writing to pipe"; break; } } if (pnb) return; if (pclose (fp) == -1) _p_error ("error closing pipe"); fp = NULL; if (lo_close (conn, lod)) msg = PQerrorMessage (conn); else success = true; lod = -1; } lo_to_pipe::~lo_to_pipe (void) { if (lod != -1) { if (lo_close (conn, lod)) _p_error ("%s", PQerrorMessage (conn)); lod = -1; } if (fp) { if (pclose (fp) == -1) _p_error ("error closing pipe"); fp = NULL; } if (commit) { std::string cmd ("commit;"); Cell params; Cell ptypes (1, 0); Cell rtypes; std::string caller ("pq_lo_export"); command c (oct_pq_conn, cmd, params, ptypes, rtypes, caller); if (c.good ()) c.process_single_result (); if (! c.good ()) _p_error ("%s: could not commit", caller.c_str ()); } } DEFUN_DLD (pq_lo_import, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{oid} =} pq_lo_import (@var{connection}, @var{path})\n\ Imports the file in @var{path} on the client side as a large object into the database associated with @var{connection} and returns the Oid of the new large object. If @var{path} ends with a @code{|}, it is take as a shell command whose output is piped into a large object.\n\ @end deftypefn") { std::string fname ("pq_lo_import"); octave_value retval; if (args.length () != 2 || args(0).type_id () != octave_pq_connection::static_type_id ()) { print_usage (); return retval; } std::string path; CHECK_ERROR (path = args(1).string_value (), retval, "%s: second argument can not be converted to a string", fname.c_str ()); bool from_pipe = false; unsigned int l = path.size (); if (l && path[l - 1] == '|') { unsigned int pos; // There seemed to be a bug in my C++ library so that // path.find_last_not_of (" \t\n\r\f", l - 1)) // returned l - 1 ! This is the workaround. path.erase (l - 1, 1); if ((pos = path.find_last_not_of (" \t\n\r\f")) == std::string::npos) { error ("%s: no command found to pipe from", fname.c_str ()); return retval; } path.erase (pos + 1, std::string::npos); from_pipe = true; } const octave_base_value& rep = (args(0).get_rep ()); const octave_pq_connection &oct_pq_conn = dynamic_cast (rep); PGconn *conn = oct_pq_conn.get_rep ()->octave_pq_get_conn (); if (! conn) { error ("%s: connection not open", fname.c_str ()); return retval; } bool make_tblock = false; switch (PQtransactionStatus (conn)) { case PQTRANS_IDLE: make_tblock = true; break; case PQTRANS_INTRANS: break; case PQTRANS_INERROR: error ("%s: can't manipulate large objects within a failed transaction block", fname.c_str ()); return retval; case PQTRANS_UNKNOWN: error ("%s: connection is bad", fname.c_str ()); return retval; default: // includes PQTRANS_ACTIVE error ("%s: unexpected connection state", fname.c_str ()); return retval; } if (make_tblock) { std::string cmd ("begin;"); Cell params; Cell ptypes (1, 0); Cell rtypes; command c (*(oct_pq_conn.get_rep ()), cmd, params, ptypes, rtypes, fname); if (c.good ()) c.process_single_result (); if (! c.good ()) { error ("%s: could not begin transaction", fname.c_str ()); return retval; } } Oid oid = 0; bool import_error = false; std::string msg; if (from_pipe) { pipe_to_lo tp (*(oct_pq_conn.get_rep ()), path.c_str (), make_tblock, msg); make_tblock = false; // commit handled by destructor of pipe_to_lo if (tp.valid ()) oid = tp.get_oid (); else import_error = true; } else if (! (oid = lo_import (conn, path.c_str ()))) { import_error = true; msg = PQerrorMessage (conn); } // if we started the transaction, commit it even in case of import failure bool commit_error = false; if (make_tblock) { std::string cmd ("commit;"); Cell params; Cell ptypes (1, 0); Cell rtypes; command c (*(oct_pq_conn.get_rep ()), cmd, params, ptypes, rtypes, fname); if (c.good ()) c.process_single_result (); if (! c.good ()) commit_error = true; } if (import_error) _p_error ("%s: large object import failed: %s", fname.c_str (), msg.c_str ()); if (commit_error) _p_error ("%s: could not commit transaction", fname.c_str ()); if (import_error || commit_error) { error ("%s failed", fname.c_str ()); return retval; } retval = octave_value (octave_uint32 (oid)); return retval; } DEFUN_DLD (pq_lo_export, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} pq_lo_export (@var{connection}, @var{oid}, @var{path})\n\ Exports the large object of Oid @var{oid} in the database associated with @var{connection} to the file @var{path} on the client side. If @var{path} starts with a @code{|}, it is taken as a shell commant to pipe to.\n\ @end deftypefn") { std::string fname ("pq_lo_export"); octave_value retval; if (args.length () != 3 || args(0).type_id () != octave_pq_connection::static_type_id ()) { print_usage (); return retval; } std::string path; CHECK_ERROR (path = args(2).string_value (), retval, "%s: third argument can not be converted to a string", fname.c_str ()); bool to_pipe = false; if (! path.empty () && path[0] == '|') { unsigned int pos; if ((pos = path.find_first_not_of (" \t\n\r\f", 1)) == std::string::npos) { error ("%s: no command found to pipe to", fname.c_str ()); return retval; } path.erase (0, pos); to_pipe = true; } Oid oid = 0; CHECK_ERROR (oid = args(1).uint_value (), retval, "%s: second argument can not be converted to an oid", fname.c_str ()); const octave_base_value& rep = (args(0).get_rep ()); const octave_pq_connection &oct_pq_conn = dynamic_cast (rep); PGconn *conn = oct_pq_conn.get_rep ()->octave_pq_get_conn (); if (! conn) { error ("%s: connection not open", fname.c_str ()); return retval; } bool make_tblock = false; switch (PQtransactionStatus (conn)) { case PQTRANS_IDLE: make_tblock = true; break; case PQTRANS_INTRANS: break; case PQTRANS_INERROR: error ("%s: can't manipulate large objects within a failed transaction block", fname.c_str ()); return retval; case PQTRANS_UNKNOWN: error ("%s: connection is bad", fname.c_str ()); return retval; default: // includes PQTRANS_ACTIVE error ("%s: unexpected connection state", fname.c_str ()); return retval; } if (make_tblock) { std::string cmd ("begin;"); Cell params; Cell ptypes (1, 0); Cell rtypes; command c (*(oct_pq_conn.get_rep ()), cmd, params, ptypes, rtypes, fname); if (c.good ()) c.process_single_result (); if (! c.good ()) { error ("%s: could not begin transaction", fname.c_str ()); return retval; } } bool export_error = false; std::string msg; if (to_pipe) { lo_to_pipe tp (*(oct_pq_conn.get_rep ()), oid, path.c_str (), make_tblock, msg); make_tblock = false; // commit handled by destructor of lo_to_pipe if (! tp.valid ()) export_error = true; } else if (lo_export (conn, oid, path.c_str ()) == -1) { export_error = true; msg = PQerrorMessage (conn); } // if we started the transaction, commit it even in case of export failure bool commit_error = false; if (make_tblock) { std::string cmd ("commit;"); Cell params; Cell ptypes (1, 0); Cell rtypes; command c (*(oct_pq_conn.get_rep ()), cmd, params, ptypes, rtypes, fname); if (c.good ()) c.process_single_result (); if (! c.good ()) commit_error = true; } if (export_error) _p_error ("%s: large object export failed: %s", fname.c_str (), msg.c_str ()); if (commit_error) _p_error ("%s: could not commit transaction", fname.c_str ()); if (export_error || commit_error) error ("%s failed", fname.c_str ()); return retval; } DEFUN_DLD (pq_lo_unlink, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} pq_lo_unlink (@var{connection}, @var{oid})\n\ Removes the large object of Oid @var{oid} from the database associated with @var{connection}.\n\ @end deftypefn") { std::string fname ("pq_lo_unlink"); octave_value retval; if (args.length () != 2 || args(0).type_id () != octave_pq_connection::static_type_id ()) { print_usage (); return retval; } Oid oid = 0; CHECK_ERROR (oid = args(1).uint_value (), retval, "%s: second argument can not be converted to an oid", fname.c_str ()); const octave_base_value& rep = (args(0).get_rep ()); const octave_pq_connection &oct_pq_conn = dynamic_cast (rep); PGconn *conn = oct_pq_conn.get_rep ()->octave_pq_get_conn (); if (! conn) { error ("%s: connection not open", fname.c_str ()); return retval; } bool make_tblock = false; switch (PQtransactionStatus (conn)) { case PQTRANS_IDLE: make_tblock = true; break; case PQTRANS_INTRANS: break; case PQTRANS_INERROR: error ("%s: can't manipulate large objects within a failed transaction block", fname.c_str ()); return retval; case PQTRANS_UNKNOWN: error ("%s: connection is bad", fname.c_str ()); return retval; default: // includes PQTRANS_ACTIVE error ("%s: unexpected connection state", fname.c_str ()); return retval; } if (make_tblock) { std::string cmd ("begin;"); Cell params; Cell ptypes (1, 0); Cell rtypes; command c (*(oct_pq_conn.get_rep ()), cmd, params, ptypes, rtypes, fname); if (c.good ()) c.process_single_result (); if (! c.good ()) { error ("%s: could not begin transaction", fname.c_str ()); return retval; } } bool unlink_error = false; std::string msg; if (lo_unlink (conn, oid) == -1) { unlink_error = true; msg = PQerrorMessage (conn); } // if we started the transaction, commit it even in case of unlink failure bool commit_error = false; if (make_tblock) { std::string cmd ("commit;"); Cell params; Cell ptypes (1, 0); Cell rtypes; command c (*(oct_pq_conn.get_rep ()), cmd, params, ptypes, rtypes, fname); if (c.good ()) c.process_single_result (); if (! c.good ()) commit_error = true; } if (unlink_error) _p_error ("%s: large object unlink failed: %s", fname.c_str (), msg.c_str ()); if (commit_error) _p_error ("%s: could not commit transaction", fname.c_str ()); if (unlink_error || commit_error) error ("%s failed", fname.c_str ()); return retval; } database-2.4.4/src/PaxHeaders.8241/pq_conninfo.cc0000644000000000000000000000013213444726064016361 xustar0030 mtime=1553181748.642723882 30 atime=1553181801.098843079 30 ctime=1553181803.415144792 database-2.4.4/src/pq_conninfo.cc0000644000175000017500000000466513444726064016645 0ustar00olafolaf00000000000000/* Copyright (C) 2013-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include "pq_connection.h" #include "error-helpers.h" // PKG_ADD: autoload ("pq_conninfo", "pq_interface.oct"); // PKG_DEL: autoload ("pq_conninfo", "pq_interface.oct", "remove"); DEFUN_DLD (pq_conninfo, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{val} =} pq_conninfo (@var{connection}, @var{label})\n\ Retrieves connection information for postgresql connection @var{connection}, specified by the string @var{label}, and returns the value of this information in @var{val}. The type of @var{val} depends on the requested information. Currently, the only recognized @var{label} is @code{'integer_datetimes'}; @var{val} is @code{true} if 8-byte date and time values are stored as integer in the server, and @code{false} if they are stored as @code{double} (which is deprecated).\n\ @end deftypefn") { std::string fname ("pq_conninfo"); octave_value retval; if (args.length () != 2 || args(0).type_id () != octave_pq_connection::static_type_id ()) { print_usage (); return retval; } std::string label; CHECK_ERROR (label = args(1).string_value (), retval, "%s: second argument can not be converted to a string", fname.c_str ()); if (label.compare ("integer_datetimes")) { error ("%s: unrecognized label %s", fname.c_str (), label.c_str ()); return retval; } const octave_base_value& rep = (args(0).get_rep ()); const octave_pq_connection &oct_pq_conn = dynamic_cast (rep); PGconn *conn = oct_pq_conn.get_rep ()->octave_pq_get_conn (); if (! conn) { error ("%s: connection not open", fname.c_str ()); return retval; } return octave_value (oct_pq_conn.get_rep ()->get_integer_datetimes ()); } database-2.4.4/src/PaxHeaders.8241/Makefile.in0000644000000000000000000000013213444726064015606 xustar0030 mtime=1553181748.551490686 30 atime=1553181799.630582085 30 ctime=1553181803.415144792 database-2.4.4/src/Makefile.in0000644000175000017500000001452013444726064016061 0ustar00olafolaf00000000000000# Makefile for database package for Octave # # Copyright (C) 2016-2019 Olaf Till # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # before cross building, pre-build at least $(TEXIFILE) natively, # e.g. with targets 'doc', 'html', or 'prebuild' CXXCPP = @CXXCPP@ MKOCTFILE ?= @MKOCTFILE@ PG_CONFIG ?= @PG_CONFIG@ OCTAVE_CONFIG ?= @OCTAVE_CONFIG@ ifndef CXXFLAGS CXXFLAGS := $(shell $(MKOCTFILE) -p CXXFLAGS) -Wall endif # OCT_LINK_OPTS should have been in stable Octave since version # 3.6. It is used here with 'mkoctfile' to specify the library # directory for external libraries (pq in this case). 'mkoctfile' puts # $(OCT_LINK_OPTS) _after_ the -L options for Octave libraries in the # resulting commandline, which is important for avoiding to link to a # wrong Octave library. -L options given in the commandline calling # 'mkoctfile' are placed differently by 'mkoctfile' in the resulting # commandline (_before_ -L options for Octave libraries). ifndef OCT_LINK_OPTS OCT_LINK_OPTS := $(shell $(MKOCTFILE) -p OCT_LINK_OPTS) endif OCT_LINK_OPTS := $(OCT_LINK_OPTS) -L$(shell $(PG_CONFIG) --libdir) # CANONICAL_HOST_TYPE := $(shell $(OCTAVE_CONFIG) -p CANONICAL_HOST_TYPE)) EXTRALIBS = ifneq (,$(findstring mingw,$(CANONICAL_HOST_TYPE))) EXTRALIBS = -lws2_32 endif octs = pq_interface.oct $(extra_octs) extra_octs = var2bytea.oct bytea2var.oct IFOBJECTS := __pq_connect__.o pq_close.o pq_exec.o converters.o \ converters_arr_comp.o pq_connection.o command.o \ pq_update_types.o pq_lo.o pq_conninfo.o __pq_internal_exit__.o \ error-helpers.o pkglock.o INFOFILE := ../doc/database.info TEXIFILE := $(addsuffix .texi,$(basename $(INFOFILE))) TXIFILE := $(addsuffix .txi,$(basename $(INFOFILE))) HTMLDIR := ../doc/html/ DEFUNDLDFILES := pq_close.cc pq_exec.cc pq_update_types.cc pq_lo.cc \ pq_conninfo.cc var2bytea.cc bytea2var.cc DSFILES := $(addsuffix .docstrings,$(DEFUNDLDFILES)) MFILES := $(wildcard *.m) $(wildcard ../inst/*.m) .PHONY: all clean distclean maintainer-clean doc prebuild html .INTERMEDIATE: MFDOCSTRINGS $(DSFILES) all: doc $(octs) prebuild: doc html pq_interface.oct: $(IFOBJECTS) OCT_LINK_OPTS="$(OCT_LINK_OPTS)" $(MKOCTFILE) -o pq_interface.oct -lpq $(IFOBJECTS) $(EXTRALIBS) %.oct: %.o error-helpers.o $(MKOCTFILE) $< error-helpers.o converters.o: converters.cc converters.h wrap_endian.h config.h error-helpers.h CXXFLAGS="$(CXXFLAGS)" $(MKOCTFILE) -I`$(PG_CONFIG) --includedir` -c converters.cc converters_arr_comp.o: converters_arr_comp.cc converters.h wrap_endian.h \ pq_connection.h command.h config.h error-helpers.h CXXFLAGS="$(CXXFLAGS)" $(MKOCTFILE) -I`$(PG_CONFIG) --includedir` -c converters_arr_comp.cc error-helpers.o: error-helpers.cc error-helpers.h config.h CXXFLAGS="$(CXXFLAGS)" $(MKOCTFILE) -c error-helpers.cc pkglock.o: pkglock.cc CXXFLAGS="$(CXXFLAGS)" $(MKOCTFILE) -c pkglock.cc # be on the safe side with respect to include files %.o: %.cc converters.h pq_connection.h command.h config.h error-helpers.h CXXFLAGS="$(CXXFLAGS)" $(MKOCTFILE) -I`$(PG_CONFIG) --includedir` -c $< doc: $(INFOFILE) $(INFOFILE): $(TEXIFILE) makeinfo $(TEXIFILE) -o $(INFOFILE) html: $(TEXIFILE) makeinfo --html -o $(HTMLDIR) $(TEXIFILE) $(TEXIFILE): $(TXIFILE) MFDOCSTRINGS $(DSFILES) munge-texi.pl ./munge-texi.pl MFDOCSTRINGS $(DSFILES) < $(TXIFILE) > $(TEXIFILE) MFDOCSTRINGS: $(MFILES) mkdoc.pl ./mkdoc.pl $(MFILES) > MFDOCSTRINGS # take long CPP macro names, unlikely to be present in package code # (which is checked) or to be defined by Octave (which can't be # checked) RDEFUN_DLD := DEFUN_DLD_REPLACEMENT_FOR_PACKAGE_DOCS RDEFUNX_DLD := DEFUNX_DLD_REPLACEMENT_FOR_PACKAGE_DOCS # Docstrings defined as C strings are obtained from a compiled C # program. This should be the cleanest way to correctly get all # special characters defined in these strings. %.cc.docstrings: %.bin (echo "### This file is generated automatically from the"; echo "### corresponding .cc file by a Makefile rule."; echo ""; ./$<) > $@ # Explanation of the command after the checks: Macro names are changed # by `sed' so that a different definition can be given to them on the # `cpp' commandline. After running the `cpp' command, one can be sure # that there are not more than one `$(RDEFUN_DLD)' resulting from a # DEFUN(X)_DLD invocation in the original code at one line, that every # occurance of `$(RDEFUN_DLD)' indeed corresponds to an original macro # invocation, and not to `DEFUN(X)_DLD' within a comment or a string, # and that we have all necessary information within one line of # text. The package code is expected to give the function # documentation as a string constant directly in the macro invocation, # as is normally done. %.bin: %.cc if grep -q $(RDEFUN_DLD) $<; then echo "The string '$(RDEFUN_DLD)' must not be present in source code, but is in $<."; exit 1; fi if grep -q $(RDEFUNX_DLD) $<; then echo "The string '$(RDEFUNX_DLD)' must not be present in source code, but is in $<."; exit 1; fi (echo "#include "; echo "int main () {"; sed -e s/DEFUN_DLD/$(RDEFUN_DLD)/g -e s/DEFUNX_DLD/$(RDEFUNX_DLD)/g $< | $(CXXCPP) `$(MKOCTFILE) -p INCFLAGS` -I`$(PG_CONFIG) --includedir` -x c++ -iquote '.' -D'$(RDEFUN_DLD)(name,args,nargout,doc)=$(RDEFUN_DLD)(name,doc)' -D'$(RDEFUNX_DLD)(name,fname,gname,args,nargout,doc)=$(RDEFUN_DLD)(name,doc)' - | sed -e '/.*$(RDEFUN_DLD)/!D'; echo "}";) | $(CXX) -x c++ -D'$(RDEFUN_DLD)(name,doc)=printf("%c" #name "\n@c " #name " $<\n" doc "\n\n", 0x1D);' -o $@ - clean: $(RM) *.o octave-core *.oct *.cc.docstrings MFDOCSTRINGS *~ distclean: $(RM) *.o octave-core *.oct *.cc.docstrings MFDOCSTRINGS *~ config.h config.log config.status maintainer-clean: $(RM) *.o octave-core *.oct *.cc.docstrings MFDOCSTRINGS *~ config.h config.log config.status $(INFOFILE) $(TEXIFILE) database-2.4.4/src/PaxHeaders.8241/bootstrap0000644000000000000000000000013213444726064015501 xustar0030 mtime=1553181748.559424007 30 atime=1553181748.694290471 30 ctime=1553181803.415144792 database-2.4.4/src/bootstrap0000755000175000017500000000005513444726064015755 0ustar00olafolaf00000000000000#! /bin/sh aclocal autoconf autoheader -f database-2.4.4/src/PaxHeaders.8241/__pq_connect__.cc0000644000000000000000000000013213444726064016775 xustar0030 mtime=1553181748.559424007 30 atime=1553181748.559424007 30 ctime=1553181803.415144792 database-2.4.4/src/__pq_connect__.cc0000644000175000017500000000310413444726064017244 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include "pq_connection.h" #include "error-helpers.h" // PKG_ADD: autoload ("__pq_connect__", "pq_interface.oct"); // PKG_DEL: autoload ("__pq_connect__", "pq_interface.oct", "remove"); DEFUN_DLD (__pq_connect__, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {@var{id}} __pq_connect__ (@var{options})\n\ Text.\n\ \n\ @end deftypefn") { std::string fname ("__pq_connect__"); octave_value retval; if (args.length () != 1) { print_usage (); return octave_value_list (); } std::string opt_string; CHECK_ERROR (opt_string = args(0).string_value (), retval, "%s: argument not a string", fname.c_str ()); octave_pq_connection *oct_pq_conn = new octave_pq_connection (opt_string); if (! oct_pq_conn->get_rep ()->octave_pq_get_conn ()) error ("%s failed", fname.c_str ()); else retval = oct_pq_conn; return retval; } database-2.4.4/src/PaxHeaders.8241/pq_connection.h0000644000000000000000000000013213444726064016551 xustar0030 mtime=1553181748.642723882 30 atime=1553181799.954646525 30 ctime=1553181803.415144792 database-2.4.4/src/pq_connection.h0000644000175000017500000000611413444726064017024 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #ifndef __OCT_PQ_CONNECTION__ #define __OCT_PQ_CONNECTION__ #include #include #include "converters.h" class octave_pq_connection_rep { public: octave_pq_connection_rep (std::string &); ~octave_pq_connection_rep (void); void octave_pq_close (void); int octave_pq_refresh_types (void); PGconn *octave_pq_get_conn (void) { return conn; } oct_pq_conv_map_t conv_map; oct_pq_name_conv_map_t name_conv_map; const bool &get_integer_datetimes (void) const { return integer_datetimes; } private: PGconn *conn; void octave_pq_delete_non_constant_types (void); // returns zero on success int octave_pq_fill_base_types (void); // returns zero on success int octave_pq_get_composite_types (void); // returns zero on success int octave_pq_get_enum_types (void); // server configuration bool integer_datetimes; }; class octave_pq_connection : public octave_base_value { public: octave_pq_connection (std::string &arg) : rep (new octave_pq_connection_rep (arg)) { static bool type_registered = false; if (! type_registered) { register_type (); type_registered = true; } } ~octave_pq_connection (void) { delete rep; } octave_pq_connection_rep *get_rep (void) const { return rep; } // Octave internal stuff bool is_constant (void) const { return true; } bool is_defined (void) const { return true; } bool is_true (void) const { return rep->octave_pq_get_conn () != 0; } void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const { indent (os); os << ""; newline (os); } void print (std::ostream& os, bool pr_as_read_syntax = false) const { print_raw (os); } // Octave changeset bcd71a2531d3 (Jan 31st 2014) made // octave_base_value::print() non-const, after that this virtual // function is not re-defined by the above print() function. Having // both const and non-const print() here seems to work both with // Octave < and >= bcd71a2531d3 (print() is only called over the // parent class virtual function). void print (std::ostream& os, bool pr_as_read_syntax = false) { print_raw (os); } bool print_as_scalar (void) const { return true; } private: // needed by Octave for register_type() octave_pq_connection (void) : rep (NULL) { } octave_pq_connection_rep *rep; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; #endif // __OCT_PQ_CONNECTION__ database-2.4.4/src/PaxHeaders.8241/mkdoc.pl0000644000000000000000000000013213444726064015173 xustar0030 mtime=1553181748.634790561 30 atime=1553181799.726601179 30 ctime=1553181803.415144792 database-2.4.4/src/mkdoc.pl0000755000175000017500000000432713444726064015455 0ustar00olafolaf00000000000000#! /usr/bin/perl -w # # Copyright (C) 2012-2013 Rik Wehbring # # This file is part of Octave. # # Octave is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3 of the License, or (at # your option) any later version. # # Octave is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License # along with Octave; see the file COPYING. If not, see # . # copied from Octave and slightly modified by Olaf Till unless (@ARGV >= 1) { die "Usage: $0 m_filename1 ..." ; } print <<__END_OF_MSG__; ### This file is generated automatically by the packages `mkdoc.pl'. __END_OF_MSG__ MFILE: foreach $full_fname (@ARGV) { next MFILE unless ( $full_fname =~ m{([^/]+)\.m$} ); $fcn = $1; @help_txt = gethelp ($fcn, $full_fname); next MFILE if ($help_txt[0] eq ""); print "\x{1d}$fcn\n"; print "\@c $fcn $full_fname\n"; foreach $_ (@help_txt) { s/^\s+\@/\@/ unless $in_example; s/^\s+\@group/\@group/; s/^\s+\@end\s+group/\@end group/; $in_example = (/\s*\@example\b/ .. /\s*\@end\s+example\b/); print $_; } } ################################################################################ # Subroutines ################################################################################ sub gethelp { ($fcn, $fname) = @_[0..1]; open (FH, $fname) or return ""; do { @help_txt = (); ## Advance to non-blank line while (defined ($_ = ) and /^\s*$/) {;} if (! /^\s*(?:#|%)/ or eof (FH)) { ## No comment block found. Return empty string close (FH); return ""; } ## Extract help text stopping when comment block ends do { ## Remove comment characters at start of line s/^\s*(?:#|%){1,2} ?//; push (@help_txt, $_); } until (! defined ($_ = ) or ! /^\s*(?:#|%)/); } until ($help_txt[0] !~ /^(?:Copyright|Author)/); close (FH); return @help_txt; } database-2.4.4/src/PaxHeaders.8241/configure.ac0000644000000000000000000000013213444726064016027 xustar0030 mtime=1553181748.595123954 30 atime=1553181748.785523667 30 ctime=1553181803.415144792 database-2.4.4/src/configure.ac0000644000175000017500000001312013444726064016275 0ustar00olafolaf00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. # ### Copyright (C) 2015-2019 Olaf Till ### ### This program is free software; you can redistribute it and/or ### modify it under the terms of the GNU General Public License as ### published by the Free Software Foundation; either version 3 of the ### License, or (at your option) any later version. ### ### This program is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ### General Public License for more details. ### ### You should have received a copy of the GNU General Public License ### along with this program; if not, see ### . AC_PREREQ([2.67]) AC_INIT([database], [2.4.4], [i7tiol@t-online.de]) AC_CONFIG_SRCDIR([__pq_connect__.cc]) AC_CONFIG_HEADERS([config.h]) # Avoid warnings for redefining AH-generated preprocessor symbols of # Octave. AH_TOP([#include "undef-ah-octave.h"]) AC_CONFIG_MACRO_DIRS([m4]) # Checks for programs. AC_CHECK_PROG(MKOCTFILE, mkoctfile, mkoctfile) if test -z "$MKOCTFILE"; then AC_MSG_ERROR([mkoctfile not found], 1); fi AC_CHECK_PROG(OCTAVE_CONFIG, octave-config, octave-config) if test -z "$OCTAVE_CONFIG"; then AC_MSG_ERROR([octave-config not found], 1); fi AC_CHECK_PROG(PG_CONFIG, pg_config, pg_config) if test -z "$PG_CONFIG"; then AC_MSG_ERROR([pg_config not found], 1); fi AC_PROG_AWK if test -z "$ac_cv_prog_AWK"; then AC_MSG_ERROR([AWK not found], 1); fi AC_PROG_SED # The same value of CXX as Octave was compiled with is supposed to be used. CXX=${CXX:-`${MKOCTFILE} -p CXX`} AC_PROG_CXX AC_PROG_CXXCPP # Checks for libraries. AC_CHECK_LIB([pq], [PQconnectdb], [], [ AC_MSG_ERROR([unable to find the PQconnectdb() function in pq]) ]) # Checks for typedefs, structures, and compiler characteristics. # Checks for library functions. AC_FUNC_ERROR_AT_LINE # Check for PostgreSQL version. AC_MSG_CHECKING([whether PostgreSQL version >= 8.3]) if `$PG_CONFIG --version | awk 'NR==1 { print $(NF); };' | awk -F '.' ' { if ( $1 > 8 || $1 == 8 && $2 >= 3 ) exit 1; else exit 0}'`; then AC_MSG_RESULT(no) AC_MSG_ERROR([package "database" does not work with PostgreSQL version < 8.3], 1); else AC_MSG_RESULT(yes) fi # Start of checks for Octave features, preparations for checks. OCTLIBDIR=${OCTLIBDIR:-`$OCTAVE_CONFIG -p OCTLIBDIR`} ## We need Octaves include path both with and without '/octave' ## appended. The path without '/octave' is needed to selectively test ## for Octave headers, like octave/....h. The path with '/octave' is ## needed since some Octave headers contain include directives for ## other Octave headers with <> instead of "". OCTINCLUDEDIR=${OCTINCLUDEDIR:-`$MKOCTFILE -p INCFLAGS`} AC_LANG_PUSH([C++]) TCXXFLAGS=$CXXFLAGS TLDFLAGS=$LDFLAGS TLIBS=$LIBS TCPPFLAGS=$CPPFLAGS LDFLAGS="-L$OCTLIBDIR $LDFLAGS" LIBS="-loctinterp $LIBS" # CXXFLAGS= CPPFLAGS="$OCTINCLUDEDIR $CPPFLAGS" ## Presence of 'error_state' -- does _not_ indicate no exceptions are ## used. AC_LINK_IFELSE( [AC_LANG_PROGRAM([[#include ] [#include ]], [[printf ("%i", error_state);]])], [AC_DEFINE([HAVE_OCTAVE_ERROR_STATE], 1, [Define as 1 if liboctinterp is old enough to provide error_state.])]) ## Presence of 'verror (octave(_|::)execution_exception&, const char *, ## va_list)' AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include ]], [[octave_execution_exception e;] [va_list args;] [verror (e, "test", args);]])], [AC_DEFINE([HAVE_OCTAVE_VERROR_ARG_EXC], 1, [Define as 1 if liboctinterp has 'verror (octave(_|::)execution_exception&, const char *, va_list)'.])], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include ]], [[octave::execution_exception e;] [va_list args;] [verror (e, "test", args);]])], [AC_DEFINE([HAVE_OCTAVE_VERROR_ARG_EXC], 1, [Define as 1 if liboctinterp has 'verror (octave(_|::)execution_exception&, const char *, va_list)'.])])]) AC_CHECK_HEADERS([octave/interpreter.h]) ## Simple symbol alternatives of different Octave versions. OF_OCTAVE_LIST_ALT_SYMS([ [dnl [oct_mach_info], [octave::mach_info], [[octave::mach_info::flt_fmt_unknown;]], [OCTAVE__MACH_INFO], [], [] ], [dnl [is_cell], [iscell], [[octave_value ().iscell ();]], [OV_ISCELL], [], [] ], [dnl [is_empty], [isempty], [[octave_value ().isempty ();]], [OV_ISEMPTY], [], [] ], [dnl [is_float_type], [isfloat], [[octave_value ().isfloat ();]], [OV_ISFLOAT], [], [] ], [dnl [is_integer_type], [isinteger], [[octave_value ().isinteger ();]], [OV_ISINTEGER], [], [] ], [dnl [is_real_type], [isreal], [[octave_value ().isreal ();]], [OV_ISREAL], [], [] ], [dnl [feval], [octave::feval], [[octave::feval ("date");]], [OCTAVE__FEVAL], [[#include ]], [[#include ]] ], [dnl [octave_execution_exception], [octave::execution_exception], [[octave::execution_exception ();]], [OCTAVE__EXECUTION_EXCEPTION], [], [] ], [dnl [octave_vformat], [octave::vformat], [[std::ostringstream obuf;] [va_list args;] [octave::vformat (obuf, "dummy", args);]], [OCTAVE__VFORMAT], [], [] ] ], [oct-alt-includes.h]) LIBS=$TLIBS LDFLAGS=$TLDFLAGS CXXFLAGS=$TCXXFLAGS CPPFLAGS=$TCPPFLAGS AC_LANG_POP([C++]) # End of checks for Octave features. AC_CONFIG_FILES([Makefile]) AC_OUTPUT database-2.4.4/src/PaxHeaders.8241/pq_close.cc0000644000000000000000000000013113444726064015654 xustar0030 mtime=1553181748.638757221 29 atime=1553181799.73460277 30 ctime=1553181803.415144792 database-2.4.4/src/pq_close.cc0000644000175000017500000000275313444726064016135 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include "pq_connection.h" // PKG_ADD: autoload ("pq_close", "pq_interface.oct"); // PKG_DEL: autoload ("pq_close", "pq_interface.oct", "remove"); DEFUN_DLD (pq_close, args, , "-*- texinfo -*-\n\ @deftypefn {Loadable Function} pq_close (@var{connection})\n\ Closes connection @var{connection} to a postgresql server.\n\ @seealso{pq_connect}\n\ @end deftypefn") { std::string fname ("pq_close"); if (args.length () != 1 || args(0).type_id () != octave_pq_connection::static_type_id ()) { print_usage (); return octave_value_list (); } const octave_base_value& rep = (args(0).get_rep ()); const octave_pq_connection &oct_pq_conn = dynamic_cast (rep); oct_pq_conn.get_rep ()->octave_pq_close (); return octave_value_list (); } database-2.4.4/src/PaxHeaders.8241/converters_arr_comp.cc0000644000000000000000000000013213444726064020124 xustar0030 mtime=1553181748.607023936 30 atime=1553181748.607023936 30 ctime=1553181803.415144792 database-2.4.4/src/converters_arr_comp.cc0000644000175000017500000004225713444726064020407 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include #include #include #include #include "converters.h" #include "pq_connection.h" #include "error-helpers.h" #define ERROR_RETURN_NO_PG_TYPE \ { \ _p_error ("could not determine postgresql type for Octave parameter"); \ return NULL; \ } oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &conn, std::string &name, pq_oct_type_t &oct_type) { oct_pq_conv_t *conv = NULL; // printf ("pgtype_from_spec(%s): simple ", name.c_str ()); oct_type = simple; // default int l; while (name.size () >= 2 && ! name.compare (l = name.size () - 2, 2, "[]")) { name.erase (l, 2); oct_type = array; // printf ("array "); } oct_pq_name_conv_map_t::const_iterator iter; if ((iter = conn.name_conv_map.find (name.c_str ())) == conn.name_conv_map.end ()) { _p_error ("no converter found for type %s", name.c_str ()); return NULL; } else { // printf ("(looked up in name map) "); conv = iter->second.get_copy (); if (oct_type == array && ! conv->aoid) { _p_error ("%s: internal error, type %s, specified as array, has no array type in system catalog", name.c_str ()); return NULL; } if (! (oct_type == array) && conv->is_composite) { oct_type = composite; // printf ("composite "); } } // printf ("\n"); return conv; } oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &conn, Oid oid, pq_oct_type_t &oct_type) { // printf ("pgtype_from_spec(%u): ", oid); oct_pq_conv_t *conv = NULL; oct_pq_conv_map_t::const_iterator iter; if ((iter = conn.conv_map.find (oid)) == conn.conv_map.end ()) { _p_error ("no converter found for element oid %u", oid); return NULL; } conv = iter->second.get_copy (); // printf ("(looked up %s in oid map) ", conv->name.c_str ()); if (conv->aoid == oid) oct_type = array; else if (conv->is_composite) oct_type = composite; else oct_type = simple; // printf ("oct_type: %i\n", oct_type); return conv; } oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &conn, Oid oid, oct_pq_conv_t *&c_conv, pq_oct_type_t &oct_type) { if (c_conv) { if (c_conv->aoid == oid) oct_type = array; else if (c_conv->is_composite) oct_type = composite; else oct_type = simple; } else c_conv = pgtype_from_spec (conn, oid, oct_type); return c_conv; } oct_pq_conv_t *pgtype_from_octtype (const octave_pq_connection_rep &conn, const octave_value ¶m) { // printf ("pgtype_from_octtype: "); if (param.is_bool_scalar ()) { // printf ("bool\n"); return conn.name_conv_map.find ("bool")->second.get_copy (); } else if (param.is_real_scalar ()) { if (param.is_double_type ()) { // printf ("float8\n"); return conn.name_conv_map.find ("float8")->second.get_copy (); } else if (param.is_single_type ()) { // printf ("float4\n"); return conn.name_conv_map.find ("float4")->second.get_copy (); } } if (param.is_scalar_type ()) { if (param.is_int16_type ()) { // printf ("int2\n"); return conn.name_conv_map.find ("int2")->second.get_copy (); } else if (param.is_int32_type ()) { // printf ("int4\n"); return conn.name_conv_map.find ("int4")->second.get_copy (); } else if (param.is_int64_type ()) { // printf ("int8\n"); return conn.name_conv_map.find ("int8")->second.get_copy (); } else if (param.is_uint32_type ()) { // printf ("oid\n"); return conn.name_conv_map.find ("oid")->second.get_copy (); } } if (param.is_uint8_type ()) { // printf ("bytea\n"); return conn.name_conv_map.find ("bytea")->second.get_copy (); } else if (param.is_string ()) { // printf ("text\n"); return conn.name_conv_map.find ("text")->second.get_copy (); } // isreal() is true for strings, so isnumeric() would // still be needed if strings were not recognized above if (param.OV_ISREAL ()) { switch (param.numel ()) { case 2: // printf ("point\n"); return conn.name_conv_map.find ("point")->second.get_copy (); case 3: // printf ("circle\n"); return conn.name_conv_map.find ("circle")->second.get_copy (); case 4: // printf ("lseg\n"); return conn.name_conv_map.find ("lseg")->second.get_copy (); } } ERROR_RETURN_NO_PG_TYPE } octave_idx_type count_row_major_order (dim_vector &dv, oct_mo_count_state &state, bool init) { if (init) { state.nd = dv.length (); state.cur.resize (state.nd); state.pd.resize (state.nd); // cannot be done with resize in multiple initializations // (resizing to n<2 not possible) and there is no fill() method for (octave_idx_type i = 0; i < state.nd; i++) { state.cur(i) = 0; state.pd(i) = 1; } for (octave_idx_type i = 0; i < state.nd - 1; i++) { state.pd(i + 1) = state.pd(i) * dv(i); } return 0; } else { octave_idx_type nd = state.nd; if (nd > 0) { octave_idx_type ret = 0; state.cur(nd - 1)++; for (octave_idx_type i = nd - 1; i > 0; i--) { if (state.cur(i) == dv(i)) { state.cur(i) = 0; state.cur(i - 1)++; } ret += state.cur(i) * state.pd(i); } if (state.cur(0) == dv(0)) ret = -1; // signals overflow else ret += state.cur(0) * state.pd(0); return ret; } else return -1; } } int from_octave_bin_array (const octave_pq_connection_rep &conn, const octave_value &oct_arr, oct_pq_dynvec_t &val, oct_pq_conv_t *conv) { octave_scalar_map m; bool err; SET_ERR (m= oct_arr.scalar_map_value (), err); if (err) { _p_error ("Postgresql array parameter no Octave structure"); return 1; } if (! m.isfield ("ndims") || ! m.isfield ("data")) { _p_error ("field 'ndims' or 'data' missing in parameter for Postgresql array"); return 1; } octave_idx_type nd_pq = 0; SET_ERR (nd_pq = m.contents ("ndims").int_value (), err); Cell arr; if (! err) { SET_ERR (arr = m.contents ("data").cell_value (), err); } if (err || nd_pq < 0) { _p_error ("'ndims' and 'data' could not be converted to non-negative integer and cell-array in parameter for Postgresql array"); return 1; } RowVector lb; // Are lbounds given? if (m.isfield ("lbounds")) { SET_ERR (lb = m.contents ("lbounds").row_vector_value (), err); if (err) { _p_error ("could not convert given enumeration bases for array to row vector"); return 1; } } octave_idx_type nl = arr.numel (); // dimensions of Octaves representation of postgresql array dim_vector d = arr.dims (); d.chop_trailing_singletons (); int nd_oct = d.length (); if (nd_oct == 2 && d(1) == 1) nd_oct = 1; // check dimensions if (nd_oct > nd_pq) { _p_error ("given representation of postgresql array has more dimensions than specified"); return 1; } // check lbounds if (nd_pq > 0 && lb.OV_ISEMPTY ()) lb.resize (nd_pq, 1); // fill with 1 else if (lb.numel () != nd_pq) { _p_error ("number of specified enumeration bases for array does not match specified number of dimensions"); return 1; } // ndim OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) nd_pq)) // always make a NULL-bitmap, we don't scan for NULLs to see if it // is really necessary OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) 1)) // element OID OCT_PQ_PUT(val, uint32_t, htobe32 ((uint32_t) conv->oid)) // dims, lbounds for (int i = 0; i < nd_pq; i++) { OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) (i < nd_oct ? d(i) : 1))) OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) lb(i))) } // elements oct_mo_count_state state; count_row_major_order (d, state, true); // initialize counter for (int i = 0, ti = 0; ti < nl; ti++, i = count_row_major_order (d, state, false)) { if (arr(i).is_real_scalar () && arr(i).isna ().bool_value ()) // a length value (uint32_t) would not have the 6 highest bits // set (while this has all bits set) { OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) -1)) } else { OCT_PQ_SET_UINT32_PLACEHOLDER(val, temp_pos) if (conv->is_composite) { if (from_octave_bin_composite (conn, arr(i), val, conv)) return 1; } else { if (conv->from_octave_bin (conn, arr(i), val)) return 1; } OCT_PQ_FILL_UINT32_PLACEHOLDER(val, temp_pos) } } return 0; } int from_octave_bin_composite (const octave_pq_connection_rep &conn, const octave_value &oct_comp, oct_pq_dynvec_t &val, oct_pq_conv_t *conv) { Cell rec; bool err; SET_ERR (rec = oct_comp.cell_value (), err); if (err) { _p_error ("Octaves representation of a composite type could not be converted to cell-array"); return 1; } octave_idx_type nl = rec.numel (); if (size_t (nl) != conv->el_oids.size ()) { _p_error ("Octaves representation of a composite type has incorrect number of elements (%i, should have %i)", nl, conv->el_oids.size ()); return 1; } // ncols OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) nl)) // elements for (int i = 0; i < nl; i++) { // element OID OCT_PQ_PUT(val, uint32_t, htobe32 ((uint32_t) conv->el_oids[i])) if (rec(i).is_real_scalar () && rec(i).isna ().bool_value ()) // a length value (uint32_t) would not have the 6 highest bits // set (while this has all bits set) { OCT_PQ_PUT(val, int32_t, htobe32 ((int32_t) -1)) } else { OCT_PQ_SET_UINT32_PLACEHOLDER(val, temp_pos) oct_pq_conv_t *el_conv; pq_oct_type_t oct_type; if (! (el_conv = pgtype_from_spec (conn, conv->el_oids[i], conv->conv_cache[i], oct_type))) return 1; switch (oct_type) { case simple: if (el_conv->from_octave_bin (conn, rec(i), val)) return 1; break; case array: if (from_octave_bin_array (conn, rec(i), val, el_conv)) return 1; break; case composite: if (from_octave_bin_composite (conn, rec(i), val, el_conv)) return 1; break; default: // should not get here _p_error ("internal error, undefined type identifier"); return 1; } OCT_PQ_FILL_UINT32_PLACEHOLDER(val, temp_pos) } } return 0; } int from_octave_str_array (const octave_pq_connection_rep &conn, const octave_value &oct_arr, oct_pq_dynvec_t &val, octave_value &type) { // not implemented _p_error ("not implemented"); return 1; return 0; } int from_octave_str_composite (const octave_pq_connection_rep &conn, const octave_value &oct_comp, oct_pq_dynvec_t &val, octave_value &type) { // not implemented _p_error ("not implemented"); return 1; return 0; } int to_octave_bin_array (const octave_pq_connection_rep &conn, const char *v, octave_value &ov, int nb, oct_pq_conv_t *conv) { const char *p = v; // ndim OCT_PQ_DECL_GET_INT32(ndim, p, int32_t) // Has NULL bitmap. Since this information is not used, comment it // out to avoid a warning and increase the pointer manually. // // OCT_PQ_DECL_GET_INT32(hasnull, p, int32_t) p += 4; // // element OID OCT_PQ_DECL_GET_INT32(oid, p, uint32_t) // check element OID if (oid != conv->oid) { _p_error ("element oid %i sent by server does not match element oid %i expected for array with oid %i", oid, conv->oid, conv->aoid); return 1; } // dims, lbounds dim_vector dv; dv.resize (ndim, 0); // ndim < 2 is treated as ndim == 2 if (ndim == 1) dv(1) = 1; RowVector lbounds (ndim); for (int i = 0; i < ndim; i++) { OCT_PQ_GET_INT32(dv(i), p, int32_t) OCT_PQ_GET_INT32(lbounds(i), p, int32_t) } // // elements octave_idx_type nl = dv.numel (); Cell c (dv); oct_mo_count_state state; count_row_major_order (dv, state, true); // initialize counter for (int i = 0, ti = 0; ti < nl; ti++, i = count_row_major_order (dv, state, false)) { OCT_PQ_DECL_GET_INT32(null_id, p, int32_t) if (null_id == -1) // NULL c(i) = octave_value (octave_NA); else { uint32_t nb_el = uint32_t (null_id); octave_value ov_el; if (conv->is_composite) { if (to_octave_bin_composite (conn, p, ov_el, nb_el, conv)) return 1; } else { if (conv->to_octave_bin (conn, p, ov_el, nb_el)) return 1; } p += nb_el; c(i) = ov_el; } } octave_scalar_map m; m.assign ("data", octave_value (c)); m.assign ("ndims", octave_value (ndim)); m.assign ("lbounds", octave_value (lbounds)); ov = octave_value (m); return 0; } int to_octave_bin_composite (const octave_pq_connection_rep &conn, const char *v, octave_value &ov, int nb, oct_pq_conv_t *conv) { const char *p = v; // ncols OCT_PQ_DECL_GET_INT32(nl, p, int32_t) // elements Cell c (nl, 1); for (int i = 0; i < nl; i++) { // element OID OCT_PQ_DECL_GET_INT32(oid, p, uint32_t) OCT_PQ_DECL_GET_INT32(null_id, p, int32_t) if (null_id == -1) // NULL c(i) = octave_value (octave_NA); else { uint32_t nb_el = uint32_t (null_id); oct_pq_conv_t *el_conv; pq_oct_type_t oct_type; if (! (el_conv = pgtype_from_spec (conn, oid, conv->conv_cache[i], oct_type))) return 1; octave_value el; switch (oct_type) { case simple: if (el_conv->to_octave_bin (conn, p, el, nb_el)) return 1; break; case array: if (to_octave_bin_array (conn, p, el, nb_el, el_conv)) return 1; break; case composite: if (to_octave_bin_composite (conn, p, el, nb_el, el_conv)) return 1; break; default: // should not get here _p_error ("internal error, undefined type identifier"); return 1; } p += nb_el; c(i) = el; } } ov = octave_value (c); return 0; } int to_octave_str_array (const octave_pq_connection_rep &conn, const char *v, octave_value &ov, int nb, oct_pq_conv_t *conv) { // not implemented _p_error ("not implemented"); return 1; return 0; } int to_octave_str_composite (const octave_pq_connection_rep &conn, const char *v, octave_value &ov, int nb, oct_pq_conv_t *conv) { // not implemented _p_error ("not implemented"); return 1; return 0; } database-2.4.4/src/PaxHeaders.8241/converters.h0000644000000000000000000000013213444726064016104 xustar0030 mtime=1553181748.603057275 30 atime=1553181799.954646525 30 ctime=1553181803.415144792 database-2.4.4/src/converters.h0000644000175000017500000002270413444726064016362 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #ifndef __OCT_PQ_CONVERTERS__ #define __OCT_PQ_CONVERTERS__ #include #include #include #include #include #include "wrap_endian.h" #define OCT_PQ_NUM_CONVERTERS 35 // The following type is used to hold data prepared for transfer from // the package to the database. There was a discussion, starting here: // http://lists.gnu.org/archive/html/octave-maintainers/2016-03/msg00183.html // which implicitely made the use of this type and of the type casts // in the macros below (OCT_PQ_PUT and the following ones) seem // questionable. // // What I (Olaf) wasn't aware while discussing this is that type // aliasing always works if one of the types is 'char'. So the type // casts in the defined macros are actually legitimate, and don't // require an -fno-strict-aliasing compiler option. So a check for g++ // to be the compiler, which seemed to be the main target of the // criticism, is actually not necessary. (I'm really sorry for the // confusion I've possibly caused.) // // Caused by the result of the discussion, there was a changeset for // using 'std::ostringstream' instead of 'std::vector' for data // preparation. This changeset was backed out again, since using // 'std::ostringstream' would require copying the data to // 'std::string' before transmission, which could get quite expensive, // e.g. with large data in bytea types. // // Apart from the check for g++ to be the compiler, the criticism also // seemed to cover the 'casting tricks' per se in the macros below, // which were considered to be replacable by a cleaner way. But the // casting enables the use of a simple assignment instruction, and // although the compiler or processor will have to perform some // mangling if the data is not aligned, this instruction is likely to // enable the compiler to chose the most efficient way for the // mangling at each system. And it spares the function call, necessary // if using 'memcpy'. typedef std::vector oct_pq_dynvec_t; // append bytes of value 'val' of type 'type' to dynamic char vector 'dv' #define OCT_PQ_PUT(dv, type, val) \ dv.resize (dv.size () + sizeof (type)); \ *((type *) &(dv.end ()[-sizeof (type)])) = val; // increase size of dynamic char vector 'dv' by size of uint32 and // store the new size in a variable named 'var' of octave_idx_type; // after further increasing 'dv', OCT_PQ_FILL_UINT32_PLACEHOLDER // should be used with equal arguments #define OCT_PQ_SET_UINT32_PLACEHOLDER(dv, var) \ octave_idx_type var = dv.size () + sizeof (uint32_t); \ dv.resize (var); // to be used after OCT_PQ_SET_UINT32_PLACEHOLDER with equal // arguments; calculate difference between current size of dynamic // char vector 'dv' and a previous size stored in a variable named // 'var', and write this difference, converted to uint32_t in network // byte order, to the placeholder within 'dv' just before the position // stored in 'var' #define OCT_PQ_FILL_UINT32_PLACEHOLDER(dv, var) \ *((uint32_t *) &(dv[var - sizeof (uint32_t)])) = htobe32 (dv.size () - var); #define OCT_PQ_DECL_GET_INT32(retvar, pointer, type) \ type retvar = be32toh (*((type *) pointer)); \ pointer += 4; #define OCT_PQ_GET_INT32(retvar, pointer, type) \ retvar = be32toh (*((type *) pointer)); \ pointer += 4; typedef enum {simple, array, composite} pq_oct_type_t; typedef struct { dim_vector pd, cur; octave_idx_type nd; } oct_mo_count_state; class octave_pq_connection_rep; typedef int (*oct_pq_to_octave_fp_t) (const octave_pq_connection_rep &, const char *, octave_value &, int); typedef int (*oct_pq_from_octave_fp_t) (const octave_pq_connection_rep &, const octave_value &, oct_pq_dynvec_t &); typedef std::vector oct_pq_el_oids_t; struct oct_pq_conv_t_; typedef std::vector oct_pq_conv_cache_t; // some objects will be constants, some will be allocated typedef struct oct_pq_conv_t_ { Oid oid; // read from server Oid aoid; // array oid // read from server oct_pq_el_oids_t el_oids; // element oids, empty for non-composite types oct_pq_conv_cache_t conv_cache; // element converter structures for //composite types bool is_composite; // false for constant objects bool is_enum; // false for constant objects bool is_not_constant; // false for constant objects // const char *name; not all constants, use std::string std::string name; oct_pq_to_octave_fp_t to_octave_str; oct_pq_to_octave_fp_t to_octave_bin; oct_pq_from_octave_fp_t from_octave_str; oct_pq_from_octave_fp_t from_octave_bin; } oct_pq_conv_t; std::string &pq_basetype_prefix (void); // a wrapper class for array of pointers to converters which qualifies // base type names in initialization class oct_pq_conv_ptrs_t { public: oct_pq_conv_ptrs_t (int n, oct_pq_conv_t **ptrs) : converters (ptrs) { for (int i = 0; i < n; i++) { std::string prefix = pq_basetype_prefix (); converters[i]->name = prefix.append (converters[i]->name); } } oct_pq_conv_t *operator[] (int i) { return converters[i]; } private: oct_pq_conv_t **converters; }; // a wrapper class around oct_pq_conv_t* to provide a default // constructor which nullifies it, for efficient use of maps, where // checking for the presence of a key while inserting it can rely on a // newly generated key mapping to a value of NULL class oct_pq_conv_wrapper_t { public: oct_pq_conv_wrapper_t (void) : conv (NULL) {} oct_pq_conv_wrapper_t (oct_pq_conv_t *c) : conv (c) {} operator oct_pq_conv_t *&(void) { return conv; } oct_pq_conv_t *&operator->(void) { return conv; } oct_pq_conv_t *get_copy (void) const { return conv; } private: oct_pq_conv_t *conv; }; typedef std::map oct_pq_conv_map_t; typedef std::map oct_pq_name_conv_map_t; // helper function for debugging void print_conv (oct_pq_conv_t *); extern oct_pq_conv_ptrs_t conv_ptrs; // these prototypes are needed because pointers to these functions are // stored in the converter structures of each found enum type int to_octave_str_text (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb); int to_octave_bin_text (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb); int from_octave_str_text (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val); int from_octave_bin_text (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val); oct_pq_conv_t *pgtype_from_octtype (const octave_pq_connection_rep &conn, const octave_value &); oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &, std::string &, pq_oct_type_t &); oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &, Oid, pq_oct_type_t &); oct_pq_conv_t *pgtype_from_spec (const octave_pq_connection_rep &, Oid, oct_pq_conv_t *&, pq_oct_type_t &); octave_idx_type count_row_major_order (dim_vector &, oct_mo_count_state &, bool); int from_octave_bin_array (const octave_pq_connection_rep &conn, const octave_value &oct_arr, oct_pq_dynvec_t &val, oct_pq_conv_t *); int from_octave_bin_composite (const octave_pq_connection_rep &conn, const octave_value &oct_comp, oct_pq_dynvec_t &val, oct_pq_conv_t *); int from_octave_str_array (const octave_pq_connection_rep &conn, const octave_value &oct_arr, oct_pq_dynvec_t &val, octave_value &type); int from_octave_str_composite (const octave_pq_connection_rep &conn, const octave_value &oct_comp, oct_pq_dynvec_t &val, octave_value &type); int to_octave_bin_array (const octave_pq_connection_rep &conn, const char *, octave_value &, int, oct_pq_conv_t *); int to_octave_bin_composite (const octave_pq_connection_rep &conn, const char *, octave_value &, int, oct_pq_conv_t *); int to_octave_str_array (const octave_pq_connection_rep &conn, const char *, octave_value &, int, oct_pq_conv_t *); int to_octave_str_composite (const octave_pq_connection_rep &conn, const char *, octave_value &, int, oct_pq_conv_t *); #endif // __OCT_PQ_CONVERTERS__ database-2.4.4/src/PaxHeaders.8241/converters.cc0000644000000000000000000000013213444726064016242 xustar0030 mtime=1553181748.603057275 30 atime=1553181748.603057275 30 ctime=1553181803.415144792 database-2.4.4/src/converters.cc0000644000175000017500000016266113444726064016527 0ustar00olafolaf00000000000000/* Copyright (C) 2012-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include #include #include #include #include #ifdef __WIN32__ #include #else #include // for AF_INET, needed in network address types #endif #include "converters.h" #include "pq_connection.h" #include "error-helpers.h" // remember to adjust OCT_PQ_NUM_CONVERTERS in converters.h #define PGSQL_AF_INET6 (AF_INET + 1) // defined so in postgresql, no // public header file available // helper function for debugging void print_conv (oct_pq_conv_t *c) { printf ("oid: %u, aoid: %u, c: %i, e: %i, nc: %i, n: %s, to_s: %i, to_b: %i, fr_s: %i, fr_b: %i,", c->oid, c->aoid, c->is_composite, c->is_enum, c->is_not_constant, c->name.c_str (), c->to_octave_str ? 1 : 0, c->to_octave_bin ? 1 : 0, c->from_octave_str ? 1 : 0, c->from_octave_bin ? 1 : 0); printf (", el_oids:"); for (size_t i = 0; i < c->el_oids.size (); i++) printf (" %u", c->el_oids[i]); printf ("\n"); } /* type bool */ int to_octave_str_bool (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { bool tp = (*c == 't' ? true : false); ov = octave_value (tp); return 0; } int to_octave_bin_bool (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ov = octave_value (bool (*c)); return 0; } int from_octave_str_bool (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { bool b, err; SET_ERR (b = ov.bool_value (), err); if (err) { _p_error ("can not convert octave_value to bool value"); return 1; } val.push_back (b ? '1' : '0'); val.push_back ('\0'); return 0; } int from_octave_bin_bool (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { bool b, err; SET_ERR (b = ov.bool_value (), err); if (err) { _p_error ("can not convert octave_value to bool value"); return 1; } val.push_back (char (b)); return 0; } oct_pq_conv_t conv_bool = {0, // 16 0, // 1000 oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "bool", &to_octave_str_bool, &to_octave_bin_bool, &from_octave_str_bool, &from_octave_bin_bool}; /* end type bool */ /* type oid */ int to_octave_str_oid (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_oid (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ov = octave_value (octave_uint32 (be32toh (*((uint32_t *) c)))); return 0; } int from_octave_str_oid (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_oid (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { uint32_t oid; bool err; SET_ERR (oid = ov.uint_value (), err); if (err) { _p_error ("can not convert octave_value to oid value"); return 1; } OCT_PQ_PUT(val, uint32_t, htobe32 (oid)) return 0; } oct_pq_conv_t conv_oid = {0, // 26 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "oid", &to_octave_str_oid, &to_octave_bin_oid, &from_octave_str_oid, &from_octave_bin_oid}; /* end type oid */ /* type float8 */ int to_octave_str_float8 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { // not implemented return 1; } int to_octave_bin_float8 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { union { double d; int64_t i; } swap; swap.i = be64toh (*((int64_t *) c)); ov = octave_value (swap.d); return 0; } int from_octave_str_float8 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { // not implemented return 1; } int from_octave_bin_float8 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { union { double d; int64_t i; } swap; bool err; SET_ERR (swap.d = ov.double_value (), err); if (err) { _p_error ("can not convert octave_value to float8 value"); return 1; } OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) return 0; } oct_pq_conv_t conv_float8 = {0, // 701 0, // 1022 oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "float8", &to_octave_str_float8, &to_octave_bin_float8, &from_octave_str_float8, &from_octave_bin_float8}; /* end type float8 */ /* type float4 */ int to_octave_str_float4 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { // not implemented return 1; } int to_octave_bin_float4 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { union { float f; int32_t i; } swap; swap.i = be32toh (*((int32_t *) c)); ov = octave_value (swap.f); return 0; } int from_octave_str_float4 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { // not implemented return 1; } int from_octave_bin_float4 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { union { float f; int32_t i; } swap; bool err; SET_ERR (swap.f = ov.float_value (), err); if (err) { _p_error ("can not convert octave_value to float4 value"); return 1; } OCT_PQ_PUT(val, int32_t, htobe32 (swap.i)) return 0; } oct_pq_conv_t conv_float4 = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "float4", &to_octave_str_float4, &to_octave_bin_float4, &from_octave_str_float4, &from_octave_bin_float4}; /* end type float4 */ /* type bytea */ int to_octave_str_bytea (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_bytea (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { uint8NDArray m (dim_vector (nb, 1)); memcpy (m.fortran_vec (), c, nb); ov = octave_value (m); return 0; } int from_octave_str_bytea (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_bytea (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { uint8NDArray b; bool err; SET_ERR (b = ov.uint8_array_value (), err); if (err) { _p_error ("can not convert octave_value to bytea representation"); return 1; } octave_idx_type nl = b.numel (); octave_idx_type csize = val.size (); val.resize (csize + nl); memcpy (&(val[csize]), b.fortran_vec (), nl); return 0; } oct_pq_conv_t conv_bytea = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "bytea", &to_octave_str_bytea, &to_octave_bin_bytea, &from_octave_str_bytea, &from_octave_bin_bytea}; /* end type bytea */ /* type text */ int to_octave_str_text (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_text (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { std::string s (c, nb); ov = octave_value (s); return 0; } int from_octave_str_text (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_text (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { std::string s; bool err; SET_ERR (s = ov.string_value (), err); if (err) { _p_error ("can not convert octave_value to string"); return 1; } octave_idx_type l = s.size (); octave_idx_type csize = val.size (); val.resize (csize + l); memcpy (&(val[csize]), s.data (), l); return 0; } oct_pq_conv_t conv_text = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "text", &to_octave_str_text, &to_octave_bin_text, &from_octave_str_text, &from_octave_bin_text}; /* end type text */ /* type varchar */ oct_pq_conv_t conv_varchar = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "varchar", &to_octave_str_text, &to_octave_bin_text, &from_octave_str_text, &from_octave_bin_text}; /* end type varchar */ /* type bpchar */ oct_pq_conv_t conv_bpchar = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "bpchar", &to_octave_str_text, &to_octave_bin_text, &from_octave_str_text, &from_octave_bin_text}; /* end type bpchar */ /* type name */ oct_pq_conv_t conv_name = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "name", &to_octave_str_text, &to_octave_bin_text, &from_octave_str_text, &from_octave_bin_text}; /* end type name */ /* type int2 */ int to_octave_str_int2 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_int2 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ov = octave_value (octave_int16 (int16_t (be16toh (*((int16_t *) c))))); return 0; } int from_octave_str_int2 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_int2 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { int16_t i2; bool err; SET_ERR (i2 = ov.int_value (), err); if (err) { _p_error ("can not convert octave_value to int2 value"); return 1; } OCT_PQ_PUT(val, int16_t, htobe16 (i2)) return 0; } oct_pq_conv_t conv_int2 = {0, // 26 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "int2", &to_octave_str_int2, &to_octave_bin_int2, &from_octave_str_int2, &from_octave_bin_int2}; /* end type int2 */ /* type int4 */ int to_octave_str_int4 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_int4 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ov = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c))))); return 0; } int from_octave_str_int4 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_int4 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { int32_t i4; bool err; SET_ERR (i4 = ov.int_value (), err); if (err) { _p_error ("can not convert octave_value to int4 value"); return 1; } OCT_PQ_PUT(val, int32_t, htobe32 (i4)) return 0; } oct_pq_conv_t conv_int4 = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "int4", &to_octave_str_int4, &to_octave_bin_int4, &from_octave_str_int4, &from_octave_bin_int4}; /* end type int4 */ /* type int8 */ int to_octave_str_int8 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_int8 (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ov = octave_value (octave_int64 (int64_t (be64toh (*((int64_t *) c))))); return 0; } int from_octave_str_int8 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_int8 (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { int64_t i8; bool err; SET_ERR (i8 = ov.int64_scalar_value (), err); if (err) { _p_error ("can not convert octave_value to int8 value"); return 1; } OCT_PQ_PUT(val, int64_t, htobe64 (i8)) return 0; } oct_pq_conv_t conv_int8 = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "int8", &to_octave_str_int8, &to_octave_bin_int8, &from_octave_str_int8, &from_octave_bin_int8}; /* end type int8 */ /* type money */ oct_pq_conv_t conv_money = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "money", &to_octave_str_int8, &to_octave_bin_int8, &from_octave_str_int8, &from_octave_bin_int8}; /* end type money */ // helpers for time types static inline octave_value time_8byte_to_octave (const char *c, const bool &int_dt) { if (int_dt) { return octave_value (octave_int64 (int64_t (be64toh (*((int64_t *) c))))); } else { union { double d; int64_t i; } swap; swap.i = be64toh (*((int64_t *) c)); return octave_value (swap.d); } } static inline int time_8byte_from_octave (const octave_value &ov, oct_pq_dynvec_t &val, const bool &int_dt) { if (int_dt) { // don't convert automatically because of possible overflow if (ov.OV_ISFLOAT ()) { _p_error ("floating point octave_value provided for 8-byte time value, but postgresql is configured for int64"); return 1; } int64_t i8; bool err; SET_ERR (i8 = ov.int64_scalar_value (), err); if (err) { _p_error ("can not convert octave_value to int64 time value"); return 1; } OCT_PQ_PUT(val, int64_t, htobe64 (i8)) return 0; } else { // don't convert automatically because of possible loss of accuracy if (ov.OV_ISINTEGER ()) { _p_error ("integer type octave_value provided for 8-byte time value, but postgresql is configured for double"); return 1; } union { double d; int64_t i; } swap; bool err; SET_ERR (swap.d = ov.double_value (), err); if (err) { _p_error ("can not convert octave_value to double time value"); return 1; } OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) return 0; } } // end helpers for time types /* type timestamp */ int to_octave_str_timestamp (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_timestamp (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ov = time_8byte_to_octave (c, conn.get_integer_datetimes ()); return 0; } int from_octave_str_timestamp (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_timestamp (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return (time_8byte_from_octave (ov, val, conn.get_integer_datetimes ())); } oct_pq_conv_t conv_timestamp = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "timestamp", &to_octave_str_timestamp, &to_octave_bin_timestamp, &from_octave_str_timestamp, &from_octave_bin_timestamp}; /* end type timestamp */ /* type timestamptz */ oct_pq_conv_t conv_timestamptz = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "timestamptz", &to_octave_str_timestamp, &to_octave_bin_timestamp, &from_octave_str_timestamp, &from_octave_bin_timestamp}; /* end type timestamptz */ /* type interval */ int to_octave_str_interval (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_interval (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { Cell tp (dim_vector (3, 1)); tp(0) = time_8byte_to_octave (c, conn.get_integer_datetimes ()); c += 8; tp(1) = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c))))); c += 4; tp(2) = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c))))); ov = octave_value (tp); return 0; } int from_octave_str_interval (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_interval (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { Cell iv; bool err; SET_ERR (iv = ov.cell_value (), err); if (err || iv.numel () != 3) { _p_error ("interval: can not convert octave_value to cell with 3 elements"); return 1; } if (time_8byte_from_octave (iv(0), val, conn.get_integer_datetimes ())) return 1; for (int id = 1; id < 3; id++) { int32_t i4; bool err; SET_ERR (i4 = iv(id).int_value (), err); if (err) { _p_error ("interval: can not convert octave_value to int4 value"); return 1; } OCT_PQ_PUT(val, int32_t, htobe32 (i4)) } return 0; } oct_pq_conv_t conv_interval = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "interval", &to_octave_str_interval, &to_octave_bin_interval, &from_octave_str_interval, &from_octave_bin_interval}; /* end type interval */ /* type time */ int to_octave_str_time (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_time (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ov = time_8byte_to_octave (c, conn.get_integer_datetimes ()); return 0; } int from_octave_str_time (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_time (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return (time_8byte_from_octave (ov, val, conn.get_integer_datetimes ())); } oct_pq_conv_t conv_time = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "time", &to_octave_str_time, &to_octave_bin_time, &from_octave_str_time, &from_octave_bin_time}; /* end type time */ /* type timetz */ int to_octave_str_timetz (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_timetz (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { Cell tp (dim_vector (2, 1)); tp(0) = time_8byte_to_octave (c, conn.get_integer_datetimes ()); c += 8; tp(1) = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c))))); ov = octave_value (tp); return 0; } int from_octave_str_timetz (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_timetz (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { Cell iv; bool err; SET_ERR (iv = ov.cell_value (), err); if (err || iv.numel () != 2) { _p_error ("timetz: can not convert octave_value to cell with 2 elements"); return 1; } if (time_8byte_from_octave (iv(0), val, conn.get_integer_datetimes ())) return 1; int32_t i4; SET_ERR (i4 = iv(1).int_value (), err); if (err) { _p_error ("timetz: can not convert octave_value to int4 value"); return 1; } OCT_PQ_PUT(val, int32_t, htobe32 (i4)) return 0; } oct_pq_conv_t conv_timetz = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "timetz", &to_octave_str_timetz, &to_octave_bin_timetz, &from_octave_str_timetz, &from_octave_bin_timetz}; /* end type timetz */ /* type date */ int to_octave_str_date (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_date (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ov = octave_value (octave_int32 (int32_t (be32toh (*((int32_t *) c))))); return 0; } int from_octave_str_date (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_date (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { int32_t i4; bool err; SET_ERR (i4 = ov.int_value (), err); if (err) { _p_error ("date: can not convert octave_value to int4 value"); return 1; } OCT_PQ_PUT(val, int32_t, htobe32 (i4)) return 0; } oct_pq_conv_t conv_date = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "date", &to_octave_str_date, &to_octave_bin_date, &from_octave_str_date, &from_octave_bin_date}; /* end type date */ /* type point */ int to_octave_str_point (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_point (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ColumnVector m (2); union { double d; int64_t i; } swap; for (int id = 0; id < 2; id++, c += 8) { swap.i = be64toh (*((int64_t *) c)); m(id) = swap.d; } ov = octave_value (m); return 0; } int from_octave_str_point (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_point (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { NDArray m; bool err; SET_ERR (m = ov.array_value (), err); if (err || m.numel () != 2) { _p_error ("can not convert octave_value to point representation"); return 1; } union { double d; int64_t i; } swap; for (int id = 0; id < 2; id++) { swap.d = m(id); OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) } return 0; } oct_pq_conv_t conv_point = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "point", &to_octave_str_point, &to_octave_bin_point, &from_octave_str_point, &from_octave_bin_point}; /* end type point */ /* type lseg */ int to_octave_str_lseg (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_lseg (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { Matrix m (2, 2); union { double d; int64_t i; } swap; for (int id = 0; id < 4; id++, c += 8) { swap.i = be64toh (*((int64_t *) c)); m(id) = swap.d; } ov = octave_value (m); return 0; } int from_octave_str_lseg (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_lseg (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { NDArray m; bool err; SET_ERR (m = ov.array_value (), err); if (err || m.numel () != 4) { _p_error ("can not convert octave_value to 4 doubles"); return 1; } union { double d; int64_t i; } swap; for (int id = 0; id < 4; id++) { swap.d = m(id); OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) } return 0; } oct_pq_conv_t conv_lseg = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "lseg", &to_octave_str_lseg, &to_octave_bin_lseg, &from_octave_str_lseg, &from_octave_bin_lseg}; /* end type lseg */ /* type line */ oct_pq_conv_t conv_line = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "line", &to_octave_str_lseg, &to_octave_bin_lseg, &from_octave_str_lseg, &from_octave_bin_lseg}; /* end type line */ /* type box */ oct_pq_conv_t conv_box = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "box", &to_octave_str_lseg, &to_octave_bin_lseg, &from_octave_str_lseg, &from_octave_bin_lseg}; /* end type box */ /* type circle */ int to_octave_str_circle (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_circle (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { ColumnVector m (3); union { double d; int64_t i; } swap; for (int id = 0; id < 3; id++, c += 8) { swap.i = be64toh (*((int64_t *) c)); m(id) = swap.d; } ov = octave_value (m); return 0; } int from_octave_str_circle (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_circle (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { NDArray m; bool err; SET_ERR (m = ov.array_value (), err); if (err || m.numel () != 3) { _p_error ("can not convert octave_value to circle representation"); return 1; } union { double d; int64_t i; } swap; for (int id = 0; id < 3; id++) { swap.d = m(id); OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) } return 0; } oct_pq_conv_t conv_circle = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "circle", &to_octave_str_circle, &to_octave_bin_circle, &from_octave_str_circle, &from_octave_bin_circle}; /* end type circle */ /* type polygon */ int to_octave_str_polygon (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_polygon (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { int32_t np = int32_t (be32toh (*((int32_t *) c))); c += 4; Matrix m (2, np); union { double d; int64_t i; } swap; for (int id = 0; id < np * 2; id++, c += 8) { swap.i = be64toh (*((int64_t *) c)); m(id) = swap.d; } ov = octave_value (m); return 0; } int from_octave_str_polygon (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_polygon (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { octave_idx_type nel; NDArray m; bool err; SET_ERR (m = ov.array_value (), err); if (err || (nel = m.numel ()) % 2) { _p_error ("can not convert octave_value to polygon representation"); return 1; } union { double d; int64_t i; } swap; int32_t np = nel / 2; OCT_PQ_PUT(val, int32_t, htobe32 (np)) for (int id = 0; id < nel; id++) { swap.d = m(id); OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) } return 0; } oct_pq_conv_t conv_polygon = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "polygon", &to_octave_str_polygon, &to_octave_bin_polygon, &from_octave_str_polygon, &from_octave_bin_polygon}; /* end type polygon */ /* type path */ int to_octave_str_path (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_path (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { bool closed = bool (*(c++)); int32_t np = int32_t (be32toh (*((int32_t *) c))); c += 4; Matrix m (2, np); union { double d; int64_t i; } swap; for (int id = 0; id < np * 2; id++, c += 8) { swap.i = be64toh (*((int64_t *) c)); m(id) = swap.d; } octave_scalar_map tp; tp.assign ("closed", octave_value (closed)); tp.assign ("path", octave_value (m)); ov = octave_value (tp); return 0; } int from_octave_str_path (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_path (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { octave_scalar_map tp; bool err; SET_ERR (tp = ov.scalar_map_value (), err); if (err || ! tp.isfield ("closed") || ! tp.isfield ("path")) { _p_error ("can not convert octave_value to path representation"); return 1; } octave_idx_type nel; char closed; SET_ERR (closed = char (tp.contents ("closed").bool_value ()), err); NDArray m; if (! err) { SET_ERR (m = tp.contents ("path").array_value (), err); } if (err || (nel = m.numel ()) % 2) { _p_error ("can not convert octave_value to path representation"); return 1; } union { double d; int64_t i; } swap; int32_t np = nel / 2; val.push_back (closed); OCT_PQ_PUT(val, int32_t, htobe32 (np)) for (int id = 0; id < nel; id++) { swap.d = m(id); OCT_PQ_PUT(val, int64_t, htobe64 (swap.i)) } return 0; } oct_pq_conv_t conv_path = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "path", &to_octave_str_path, &to_octave_bin_path, &from_octave_str_path, &from_octave_bin_path}; /* end type path */ /* type unknown */ // These are pseudo-converters for postgresql type 'unknown'. They do // nothing except signalling an error. The rationale is that the only // values of type 'unknown' may be NULL, in which case the converter // will not be called, but because a converter exists there won't be a // "no converter found" error thrown. int to_octave_str_unknown (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { _p_error ("can not convert postgresql type 'unknown'"); return 1; } int to_octave_bin_unknown (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { _p_error ("can not convert postgresql type 'unknown'"); return 1; } int from_octave_str_unknown (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { _p_error ("can not convert postgresql type 'unknown'"); return 1; } int from_octave_bin_unknown (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { _p_error ("can not convert postgresql type 'unknown'"); return 1; } oct_pq_conv_t conv_unknown = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "unknown", &to_octave_str_unknown, &to_octave_bin_unknown, &from_octave_str_unknown, &from_octave_bin_unknown}; /* end type unknown */ // helpers for network types static inline int to_octave_bin_cidr_inet (const char *c, octave_value &ov, bool &cidr) { int8_t nb; if (*(c++) == AF_INET) { uint8NDArray a (dim_vector (5, 1), 0); a(4) = uint8_t (*(c++)); // number of set mask bits cidr = *(c++); nb = *(c++); if (nb < 0) nb = 0; if (nb > 4) { _p_error ("internal error: received too many bytes for AF_INET type"); return 1; } memcpy (a.fortran_vec (), c, nb); ov = octave_value (a); } else { uint16NDArray a (dim_vector (9, 1), 0); a(8) = uint16_t (uint8_t (*(c++))); // number of set mask bits cidr = *(c++); nb = *(c++); if (nb < 0) nb = 0; if (nb > 16) { _p_error ("internal error: received too many bytes for AF_INET6 type"); return 1; } int8_t n = nb / 2; bool odd = nb % 2; for (int8_t i = 0; i < n; i++, c += 2) a(i) = uint16_t (be16toh (*((uint16_t *) c))); if (odd) { uint16_t tp = *c; a(n) = uint16_t (be16toh (tp)); } ov = octave_value (a); } return 0; } static inline int from_octave_bin_cidr_inet (const octave_value &ov, oct_pq_dynvec_t &val, bool cidr) { int nl = ov.numel (); uint8_t n_mbits; bool err; if (nl == 4 || nl == 5) { uint8NDArray a; SET_ERR (a = ov.uint8_array_value (), err); if (err) { _p_error ("can not convert octave_value to network type representation"); return 1; } if (nl == 5) n_mbits = a(4).value (); else n_mbits = 32; val.push_back (AF_INET); val.push_back (n_mbits); val.push_back (cidr); val.push_back (4); octave_idx_type csize = val.size (); val.resize (csize + 4); memcpy (&(val[csize]), a.fortran_vec (), 4); } else if (nl == 8 || nl == 9) { uint16NDArray a; SET_ERR (a = ov.uint16_array_value (), err); if (err) { _p_error ("can not convert octave_value to network type representation"); return 1; } if (nl == 9) n_mbits = a(8).value (); else n_mbits = 128; val.push_back (PGSQL_AF_INET6); val.push_back (n_mbits); val.push_back (cidr); val.push_back (16); for (int i = 0; i < 8; i++) { OCT_PQ_PUT(val, uint16_t, htobe16(a(i).value ())) } } else { _p_error ("invalid network type representation"); return 1; } return 0; } // end helpers for network types /* type cidr */ int to_octave_str_cidr (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_cidr (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { bool cidr = false; if (to_octave_bin_cidr_inet (c, ov, cidr)) return 1; if (! cidr) { _p_error ("internal error: unexpected flag in cidr type"); return 1; } return 0; } int from_octave_str_cidr (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_cidr (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return from_octave_bin_cidr_inet (ov, val, true); } oct_pq_conv_t conv_cidr = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "cidr", &to_octave_str_cidr, &to_octave_bin_cidr, &from_octave_str_cidr, &from_octave_bin_cidr}; /* end type cidr */ /* type inet */ int to_octave_str_inet (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_inet (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { bool cidr = false; if (to_octave_bin_cidr_inet (c, ov, cidr)) return 1; if (cidr) { _p_error ("internal error: unexpected flag in inet type"); return 1; } return 0; } int from_octave_str_inet (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_inet (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return from_octave_bin_cidr_inet (ov, val, false); } oct_pq_conv_t conv_inet = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "inet", &to_octave_str_inet, &to_octave_bin_inet, &from_octave_str_inet, &from_octave_bin_inet}; /* end type inet */ /* type macaddr */ int to_octave_str_macaddr (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_macaddr (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { uint8NDArray a (dim_vector (6, 1)); memcpy (a.fortran_vec (), c, 6); ov = octave_value (a); return 0; } int from_octave_str_macaddr (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_macaddr (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { uint8NDArray a; bool err; SET_ERR (a = ov.uint8_array_value (), err); if (err) { _p_error ("can not convert octave_value to macaddr representation"); return 1; } if (a.numel () != 6) { _p_error ("macaddr representation must have 6 elements"); return 1; } octave_idx_type csize = val.size (); val.resize (csize + 6); memcpy (&(val[csize]), a.fortran_vec (), 6); return 0; } oct_pq_conv_t conv_macaddr = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "macaddr", &to_octave_str_macaddr, &to_octave_bin_macaddr, &from_octave_str_macaddr, &from_octave_bin_macaddr}; /* end type macaddr */ /* type bit */ int to_octave_str_bit (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_bit (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { int32_t nbits = int32_t (be32toh (*((int32_t *) c))); c += 4; int32_t nbytes = (nbits + 7) / 8; uint8NDArray a (dim_vector (nbytes, 1)); memcpy (a.fortran_vec (), c, nbytes); octave_scalar_map tp; tp.assign ("bitlen", octave_value (octave_int32 (nbits))); tp.assign ("bits", octave_value (a)); ov = octave_value (tp); return 0; } int from_octave_str_bit (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_bit (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { octave_scalar_map tp; bool err; SET_ERR (tp = ov.scalar_map_value (), err); if (err || ! tp.isfield ("bitlen") || ! tp.isfield ("bits")) { _p_error ("can not convert octave_value to bitstring representation"); return 1; } int32_t nbits = 0; SET_ERR (nbits = tp.contents ("bitlen").int_value (), err); uint8NDArray a; if (! err) { SET_ERR (a = tp.contents ("bits").uint8_array_value (), err); } if (err || nbits < 0) { _p_error ("can not convert octave_value to bitstring representation"); return 1; } int32_t nbytes = (nbits + 7) / 8; if (a.numel () != nbytes) { _p_error ("wrong number of elements in bitstring representation"); return 1; } OCT_PQ_PUT(val, int32_t, htobe32 (nbits)) octave_idx_type csize = val.size (); val.resize (csize + nbytes); memcpy (&(val[csize]), a.fortran_vec (), nbytes); return 0; } oct_pq_conv_t conv_bit = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "bit", &to_octave_str_bit, &to_octave_bin_bit, &from_octave_str_bit, &from_octave_bin_bit}; /* end type bit */ /* type varbit */ oct_pq_conv_t conv_varbit = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "varbit", &to_octave_str_bit, &to_octave_bin_bit, &from_octave_str_bit, &from_octave_bin_bit}; /* end type varbit */ /* type uuid */ int to_octave_str_uuid (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_uuid (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { uint8NDArray m (dim_vector (16, 1)); memcpy (m.fortran_vec (), c, 16); ov = octave_value (m); return 0; } int from_octave_str_uuid (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_uuid (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { uint8NDArray b; bool err; SET_ERR (b = ov.uint8_array_value (), err); if (err) { _p_error ("can not convert octave_value to uuid representation"); return 1; } if (b.numel () != 16) { _p_error ("uuid representation must have 16 elements"); return 1; } octave_idx_type csize = val.size (); val.resize (csize + 16); memcpy (&(val[csize]), b.fortran_vec (), 16); return 0; } oct_pq_conv_t conv_uuid = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "uuid", &to_octave_str_uuid, &to_octave_bin_uuid, &from_octave_str_uuid, &from_octave_bin_uuid}; /* end type uuid */ /* type xml */ int to_octave_str_xml (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_xml (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { std::string s (c, nb); ov = octave_value (s); return 0; } int from_octave_str_xml (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_xml (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { std::string s; bool err; SET_ERR (s = ov.string_value (), err); if (err) { _p_error ("can not convert octave_value to string"); return 1; } octave_idx_type l = s.size (); octave_idx_type csize = val.size (); val.resize (csize + l); memcpy (&(val[csize]), s.data (), l); return 0; } oct_pq_conv_t conv_xml = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "xml", &to_octave_str_text, &to_octave_bin_text, &from_octave_str_text, &from_octave_bin_text}; /* end type xml */ /* type record */ int to_octave_str_record (const octave_pq_connection_rep &conn, const char *c, octave_value &ov, int nb) { return 1; } int to_octave_bin_record (const octave_pq_connection_rep &conn, const char *v, octave_value &ov, int nb) { const char *p = v; // ncols OCT_PQ_DECL_GET_INT32(nl, p, int32_t) // elements Cell c (nl, 1); for (int i = 0; i < nl; i++) { // element OID OCT_PQ_DECL_GET_INT32(oid, p, uint32_t) OCT_PQ_DECL_GET_INT32(null_id, p, int32_t) if (null_id == -1) // NULL c(i) = octave_value (octave_NA); else { uint32_t nb_el = uint32_t (null_id); oct_pq_conv_t *el_conv; pq_oct_type_t oct_type; if (! (el_conv = pgtype_from_spec (conn, oid, oct_type))) return 1; octave_value el; switch (oct_type) { case simple: if (el_conv->to_octave_bin (conn, p, el, nb_el)) return 1; break; case array: if (to_octave_bin_array (conn, p, el, nb_el, el_conv)) return 1; break; case composite: if (to_octave_bin_composite (conn, p, el, nb_el, el_conv)) return 1; break; default: // should not get here _p_error ("'record' converter: internal error, undefined type identifier"); return 1; } p += nb_el; c(i) = el; } } ov = octave_value (c); return 0; } int from_octave_str_record (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { return 1; } int from_octave_bin_record (const octave_pq_connection_rep &conn, const octave_value &ov, oct_pq_dynvec_t &val) { _p_error ("Type 'record' can't be sent to postgresql."); return 1; } oct_pq_conv_t conv_record = {0, 0, oct_pq_el_oids_t (), oct_pq_conv_cache_t (), false, false, false, "record", &to_octave_str_record, &to_octave_bin_record, &from_octave_str_record, &from_octave_bin_record}; /* end type record */ oct_pq_conv_t *t_conv_ptrs[OCT_PQ_NUM_CONVERTERS] = {&conv_bool, &conv_oid, &conv_float8, &conv_float4, &conv_text, &conv_varchar, &conv_bpchar, &conv_name, &conv_bytea, &conv_int2, &conv_int4, &conv_int8, &conv_money, &conv_timestamp, &conv_timestamptz, &conv_interval, &conv_time, &conv_timetz, &conv_date, &conv_point, &conv_lseg, &conv_line, &conv_box, &conv_circle, &conv_polygon, &conv_path, &conv_unknown, &conv_cidr, &conv_inet, &conv_macaddr, &conv_bit, &conv_varbit, &conv_uuid, &conv_xml, &conv_record}; oct_pq_conv_ptrs_t conv_ptrs (OCT_PQ_NUM_CONVERTERS, t_conv_ptrs); database-2.4.4/src/PaxHeaders.8241/error-helpers.h0000644000000000000000000000013213444726064016503 xustar0030 mtime=1553181748.610990596 30 atime=1553181800.290705842 30 ctime=1553181803.415144792 database-2.4.4/src/error-helpers.h0000644000175000017500000000676513444726064016772 0ustar00olafolaf00000000000000/* Copyright (C) 2016-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include "config.h" #include // Octaves non-static verror functions: The elder all set error_state, // the newer, present from the time on at which error started to throw // an exception, all throw, too. // call verror, for _linking_ also against Octave versions who have no // verror() with these arguments #ifdef HAVE_OCTAVE_VERROR_ARG_EXC void c_verror (OCTAVE__EXECUTION_EXCEPTION&, const char *, ...); #else void c_verror (const OCTAVE__EXECUTION_EXCEPTION&, const char *, ...); #endif void _p_error (const char *fmt, ...); // Print a message if 'code' causes an error and raise an error again, // both if Octave uses exceptions for errors and if it still uses // error_state. In the latter case return 'retval'. #ifdef HAVE_OCTAVE_ERROR_STATE // can throw OCTAVE__EXECUTION_EXCEPTION despite of this #define CHECK_ERROR(code, retval, ...) \ try \ { \ code ; \ \ if (error_state) \ { \ error (__VA_ARGS__); \ \ return retval; \ } \ } \ catch (OCTAVE__EXECUTION_EXCEPTION& e) \ { \ c_verror (e, __VA_ARGS__); \ } #else #define CHECK_ERROR(code, retval, ...) \ try \ { \ code ; \ } \ catch (OCTAVE__EXECUTION_EXCEPTION& e) \ { \ verror (e, __VA_ARGS__); \ } #endif // If 'code' causes an error, print a message and call exit(1) if // Octave doesn't throw exceptions for errors but still uses // error_state. #ifdef HAVE_OCTAVE_ERROR_STATE // can throw OCTAVE__EXECUTION_EXCEPTION despite of this #define CHECK_ERROR_EXIT1(code, ...) \ try \ { \ code ; \ \ if (error_state) \ { \ _p_error (__VA_ARGS__); \ \ exit (1); \ } \ } \ catch (OCTAVE__EXECUTION_EXCEPTION&) \ { \ _p_error (__VA_ARGS__); \ \ exit (1); \ } #else #define CHECK_ERROR_EXIT1(code, ...) \ try \ { \ code ; \ } \ catch (OCTAVE__EXECUTION_EXCEPTION&) \ { \ _p_error (__VA_ARGS__); \ \ exit (1); \ } #endif // Set 'err' to true if 'code' causes an error, else to false; both if // Octave uses exceptions for errors and if it still uses // error_state. In the latter case reset error_state to 0. #ifdef HAVE_OCTAVE_ERROR_STATE // can throw OCTAVE__EXECUTION_EXCEPTION despite of this #define SET_ERR(code, err) \ err = false; \ \ try \ { \ code ; \ if (error_state) \ { \ error_state = 0; \ err = true; \ } \ } \ catch (OCTAVE__EXECUTION_EXCEPTION&) \ { \ err = true; \ } #else #define SET_ERR(code, err) \ err = false; \ \ try \ { \ code ; \ } \ catch (OCTAVE__EXECUTION_EXCEPTION&) \ { \ err = true; \ } #endif database-2.4.4/src/PaxHeaders.8241/bytea2var.cc0000644000000000000000000000013213444726064015747 xustar0030 mtime=1553181748.591157293 30 atime=1553181801.750939656 30 ctime=1553181803.415144792 database-2.4.4/src/bytea2var.cc0000644000175000017500000000647213444726064016231 0ustar00olafolaf00000000000000/* Copyright (C) 2016-2019 Olaf Till This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; If not, see . */ #include #include #include #include #include "error-helpers.h" DEFUN_DLD (bytea2var, args, nout, "-*- texinfo -*-\n\ @deftypefn {Loadable Function} {} bytea2var (@var{value}, @dots{})\n\ Restore variable values from uint8 arrays generated with @code{var2bytea}.\n\ \n\ Returns as many output variables as input variables are given.\n\ \n\ @seealso{var2bytea}\n\ @end deftypefn") { std::string fname ("bytea2var"); octave_idx_type nargs = args.length (); octave_idx_type nvars = nout < nargs ? nout : nargs; octave_value_list retval (nvars); bool err = false; octave_idx_type i; for (i = 0; i < nvars; i++) { uint8NDArray m; octave_value val; CHECK_ERROR (m = args(i).uint8_array_value (), retval, "%s: could not convert argument %li to uint8 array", fname.c_str (), i + 1); octave_idx_type nel = m.numel (); std::string s ((char *) m.fortran_vec (), nel); std::istringstream is (s); bool swap; OCTAVE__MACH_INFO::float_format flt_fmt; /* slightly changed from load-save.cc (read_binary_file_header()) to reduce storage size */ const int magic_len = 2; char magic[magic_len+1]; is.read (magic, magic_len); magic[magic_len] = '\0'; if (strncmp (magic, "1L", magic_len) == 0) swap = OCTAVE__MACH_INFO::words_big_endian (); else if (strncmp (magic, "1B", magic_len) == 0) swap = ! OCTAVE__MACH_INFO::words_big_endian (); else { error ("%s: could not read binary header", fname.c_str ()); return retval; } char tmp = 0; is.read (&tmp, 1); flt_fmt = mopt_digit_to_float_format (tmp); if (flt_fmt == OCTAVE__MACH_INFO::flt_fmt_unknown) { error ("%s: unrecognized binary format", fname.c_str ()); return retval; } int32_t len; if (! is.read (reinterpret_cast (&len), 4)) { err = true; break; } if (swap) swap_bytes<4> (&len); { OCTAVE_LOCAL_BUFFER (char, buf, len+1); if (! is.read (buf, len)) { err = true; break; } buf[len] = '\0'; std::string typ (buf); val = octave_value_typeinfo::lookup_type (typ); } if (! val.load_binary (is, swap, flt_fmt)) { err = true; break; } retval(i) = val; } if (err) error ("%s: could not load variable %li", fname.c_str (), i + 1); return retval; } database-2.4.4/PaxHeaders.8241/inst0000644000000000000000000000013213444726064013652 xustar0030 mtime=1553181748.547524025 30 atime=1553181803.415144792 30 ctime=1553181803.415144792 database-2.4.4/inst/0000755000175000017500000000000013444726064014200 5ustar00olafolaf00000000000000database-2.4.4/inst/PaxHeaders.8241/database_doc.m0000644000000000000000000000013213444726064016476 xustar0030 mtime=1553181748.539590704 30 atime=1553181799.730601974 30 ctime=1553181803.415144792 database-2.4.4/inst/database_doc.m0000644000175000017500000000514613444726064016755 0ustar00olafolaf00000000000000## Copyright (C) 2014-2019 Olaf Till ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} database_doc () ## @deftypefnx {Function File} {} database_doc (@var{keyword}) ## Show database package documentation. ## ## Runs the info viewer Octave is configured with on the documentation ## in info format of the installed database package. Without argument, ## the top node of the documentation is displayed. With an argument, ## the respective index entry is searched for and its node displayed. ## ## @end deftypefn function database_doc (keyword) if ((nargs = nargin ()) > 1) print_usage () endif ## locate installed documentation persistent infopath = ""; if (isempty (infopath)) [local_list, global_list] = pkg ("list"); if (! isempty (idx = ... find (strcmp ("database", {structcat(1, local_list{:}).name}), 1))) idir = local_list{idx}.dir; elseif (! isempty (idx = ... find (strcmp ("database", {structcat(1, global_list{:}).name}), 1))) idir = global_list{idx}.dir; else error ("no installed database package found"); endif infopath = fullfile (idir, "doc/", "database.info"); ## allow for .gz if (! exist (infopath, "file")) infopath = strcat (infopath, ".gz"); endif endif ## display info INFO = info_program (); if (nargs) error_hint = ", maybe the keyword was not found in the index"; status = system (sprintf ("%s %s --index-search \"%s\"", INFO, infopath, keyword)); else error_hint = ""; status = system (sprintf ("%s %s", INFO, infopath)); endif if (status) if (status == 127) error ("unable to find info program `%s'", INFO); else error ("info program `%s' returned error code %i%s", INFO, status, error_hint); endif endif endfunction database-2.4.4/inst/PaxHeaders.8241/pq_connect.m0000644000000000000000000000013213444726064016236 xustar0030 mtime=1553181748.543557365 30 atime=1553181799.730601974 30 ctime=1553181803.415144792 database-2.4.4/inst/pq_connect.m0000644000175000017500000002042713444726064016514 0ustar00olafolaf00000000000000## Copyright (C) 2012-2019 Olaf Till ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{connection} =} pq_connect (@var{settings}) ## Establishes a connection to a postgresql server according to ## @var{settings} and returns an @code{octave_pq_connection} object ## @var{connection} which can be passed to other functions of the ## package. There can be multiple connections. An ## @code{octave_pq_connection} object contains information on a ## connection and will be internally altered by the packages functions ## even though it is only passed as an argument, i.e. Octaves 'pass by ## value' semantics are not adhered to in this case. ## ## @var{settings} can be set by @code{setdbopts} (copied from Octaves ## @code{optimset}) and can contain (defaults depend on Postgresql): ## @code{host} (hostname), @code{hostaddr} (numeric host address), ## @code{port} (port to connect to), @code{dbname} (database to connect ## to), @code{user} (user name to connect as), @code{password}, ## @code{connect_timeout}, @code{options} (command-line options to send ## to the server at run-time, see Postgresql documentation), ## @code{sslmode} (@code{disable}, @code{allow}, @code{prefer}, ## @code{require}, @code{verify-ca}, or @code{verify-full}; see ## Postgresql documentation of SSL support), @code{sslcert} (file name ## of client SSL certificate), @code{sslkey} (location of secret key for ## client certificate, file name or external OpenSSL engine ## (colon-separated engine name and an engine-specific key identifier)), ## @code{sslrootcert} (file name of root SSL certificate), @code{sslcrl} ## (file name of SSL certificate revocation list), @code{krbsrvname} ## (kerberos service name), @code{service} (service name in ## pq_service.conf to use for additional parameters). ## ## All these settings are passed to the server as they are, so it may be ## better to consult the postgresql documentation for them, e.g. the ## documentation of the PQconnectdb function in libpq. ## @seealso {pq_exec_params, pq_update_types} ## @end deftypefn ## PKG_ADD: [~] = __all_db_opts__ ("pq_connect"); function conn = pq_connect (settings) if (nargin != 1) print_usage () endif if (ischar (settings) && strcmp (settings, "defaults")) conn = setdbopts ("host", [], ... "hostaddr", [], ... "port", [], ... "dbname", [], ... "user", [], ... "password", [], ... "connect_timeout", [], ... "options", [], ... "sslmode", [], ... "sslcert", [], ... "sslkey", [], ... "sslrootcert", [], ... "sslcrl", [], ... "krbsrvname", [], ... "service", []); return; endif if (! isempty (to = getdbopts (settings, "connect_timeout")) && ... isnumeric (to)) settings = setdbopts (settings, "connect_timeout", num2str (to)); endif if (isfield (settings, "password") && isempty (settings.password)) ## I know this is far from elegant, but it seems robust and I'm to ## lazy now to find out a more decent way. printf ("password: "); fflush (stdout); password = ""; while (true) c = kbhit (); if (c == "\n") printf ("\n"); break; else password = sprintf ("%s%s", password, c); endif endwhile settings.password = password; endif optstring = ""; for [val, key] = settings if (isempty (val)) val = ""; endif val = strrep (val, '\', '\\'); val = strrep (val, "'", "''"); optstring = sprintf ("%s%s='%s' ", optstring, key, val); endfor conn = __pq_connect__ (optstring); endfunction %!demo %! conn = pq_connect (setdbopts ("dbname", "test")); %! pq_exec_params (conn, "create table testtable (t text, i int2, b bytea);") %! pq_exec_params (conn, "insert into testtable values ($1, $2, $3);", {"name1", 1, uint8([2, 4, 5])}) %! pq_exec_params (conn, "insert into testtable values ($1, $2, $3);", {"name2", 2, uint8([7, 9, 3, 1])}) %! pq_exec_params (conn, "select * from testtable;") %! pq_exec_params (conn, "drop table testtable;") %! pq_close (conn); %!demo %! ## recursive type, array-composite-array %! conn = pq_connect (setdbopts ("dbname", "test")); %! pq_exec_params (conn, "create type complex_bool_array_type as (b bool, ba bool[]);") %! pq_exec_params (conn, "create table complex_bool_array_array (a complex_bool_array_type[]);") %! pq_update_types (conn); %! 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[]"})) %! data = pq_exec_params (conn, "select * from complex_bool_array_array;").data; %! ## copy in from variable %! 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[]"})) %! pq_exec_params (conn, "select * from complex_bool_array_array;") %! ## recursive type, composite-composite-array %! pq_exec_params (conn, "create type complex_complex_bool_array_type as (b bool, c complex_bool_array_type);") %! pq_exec_params (conn, "create table complex_complex_bool_array (a complex_complex_bool_array_type);") %! pq_update_types (conn); %! 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"})) %! data = pq_exec_params (conn, "select * from complex_complex_bool_array").data; %! ## copy in from variable %! 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"})) %! pq_exec_params (conn, "select * from complex_complex_bool_array") %! pq_exec_params (conn, "drop table complex_complex_bool_array;") %! pq_exec_params (conn, "drop table complex_bool_array_array;") %! pq_exec_params (conn, "drop type complex_complex_bool_array_type;") %! pq_exec_params (conn, "drop type complex_bool_array_type;") %! pq_close (conn); %!test %! conn = pq_connect (setdbopts ("dbname", "test")); %! assert (islogical (t = pq_exec_params (conn, "select ($1);", {true}).data{1}) && t == true); %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {uint32(3)}).data{1}), "uint32 scalar") && t == 3); %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {.5}).data{1}), "scalar") && t == .5); %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {single(.5)}).data{1}), "float scalar") && t == .5); %! assert ((strcmp (ti = typeinfo (t = pq_exec_params (conn, "select ($1);", {"abc"}).data{1}), "string") || strcmp (ti, "sq_string")) && strcmp (t, "abc")); %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {uint8([2, 3])}).data{1}), "uint8 matrix") && isequal (t, [2; 3])); %! t = {20, struct("b", "abc")}; %! assert (isequal (t, bytea2var (pq_exec_params (conn, "select ($1);", {var2bytea(t)}).data{1}))); %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {int16(-2)}).data{1}), "int16 scalar") && t == int16 (-2)); %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {int32(-2)}).data{1}), "int32 scalar") && t == int32 (-2)); %! assert (strcmp (typeinfo (t = pq_exec_params (conn, "select ($1);", {int64(-2)}).data{1}), "int64 scalar") && t == int64 (-2)); %! pq_close (conn); database-2.4.4/inst/PaxHeaders.8241/getdbopts.m0000644000000000000000000000013213444726064016100 xustar0030 mtime=1553181748.543557365 30 atime=1553181799.730601974 30 ctime=1553181803.415144792 database-2.4.4/inst/getdbopts.m0000644000175000017500000000336013444726064016353 0ustar00olafolaf00000000000000## Copyright (C) 2012 Jaroslav Hajek ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} getdbopts (@var{options}, @var{parname}) ## @deftypefnx {Function File} {} getdbopts (@var{options}, @var{parname}, @var{default}) ## Return a specific setting from a structure created by ## @code{setdbopts}. If @var{parname} is not a field of the @var{options} ## structure, return @var{default} if supplied, otherwise return an ## empty matrix. ## ## (This function uses the code of Octaves 'optimget' function.) ## @end deftypefn ## Copied from Octave (was 'optimget') (Olaf Till ). function retval = getdbopts (options, parname, default) if (nargin < 2 || nargin > 4 || ! isstruct (options) || ! ischar (parname)) print_usage (); endif opts = __all_db_opts__ (); idx = lookup (tolower (opts), tolower (parname), "m"); if (idx) parname = opts{idx}; else warning ("unrecognized option: %s", parname); endif if (isfield (options, parname)) retval = options.(parname); elseif (nargin > 2) retval = default; else retval = []; endif endfunction database-2.4.4/inst/PaxHeaders.8241/__all_db_opts__.m0000644000000000000000000000013213444726064017163 xustar0030 mtime=1553181748.539590704 30 atime=1553181799.730601974 30 ctime=1553181803.415144792 database-2.4.4/inst/__all_db_opts__.m0000644000175000017500000000377313444726064017446 0ustar00olafolaf00000000000000## Copyright (C) 2012 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{names} =} __all_db_opts__ (@dots{}) ## Undocumented internal function. ## @end deftypefn ## Query all options from all known database functions and return a list ## of possible values. ## Copied from Octave (was '__all_opts__') (Olaf Till ## ). function names = __all_db_opts__ (varargin) persistent saved_names = {}; ## do not clear this function mlock (); ## guard against recursive calls. persistent recursive = false; if (recursive) names = {}; elseif (nargin == 0) names = saved_names; else ## query all options from all known functions. These will call setdbopts, ## which will in turn call us, but we won't answer. recursive = true; names = saved_names; for i = 1:nargin try opts = setdbopts (varargin{i}); fn = fieldnames (opts).'; names = [names, fn]; catch # throw the error as a warning. warning (lasterr ()); end_try_catch endfor names = unique (names); [lnames, idx] = unique (tolower (names)); if (length (lnames) < length (names)) ## This is bad. error ("duplicate options with inconsistent case"); else names = names(idx); endif saved_names = names; recursive = false; endif endfunction database-2.4.4/inst/PaxHeaders.8241/setdbopts.m0000644000000000000000000000013213444726064016114 xustar0030 mtime=1553181748.547524025 30 atime=1553181799.730601974 30 ctime=1553181803.415144792 database-2.4.4/inst/setdbopts.m0000644000175000017500000000751113444726064016371 0ustar00olafolaf00000000000000## Copyright (C) 2012 John W. Eaton ## ## Copyright (C) 2012 VZLU Prague ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## -*- texinfo -*- ## @deftypefn {Function File} {} setdbopts () ## @deftypefnx {Function File} {} setdbopts (@var{par}, @var{val}, @dots{}) ## @deftypefnx {Function File} {} setdbopts (@var{old}, @var{par}, @var{val}, @dots{}) ## @deftypefnx {Function File} {} setdbopts (@var{old}, @var{new}) ## Create settings structure for database functions. ## ## When called without any input or output arguments, 'setdbopts' ## prints a list of all valid optimization parameters. ## ## When called with one output and no inputs, return an options ## structure with all valid option parameters initialized to '[]'. ## ## When called with a list of parameter/value pairs, return an options ## structure with only the named parameters initialized. ## ## When the first input is an existing options structure OLD, the ## values are updated from either the PAR/VAL list or from the options ## structure NEW. ## ## Please see individual database functions for valid settings. ## ## (Most of this documentation and this functions code are copied from ## Octaves 'optimset' function.) ## @end deftypefn ## Copied from Octave (was 'optimset') (Olaf Till ). function retval = setdbopts (varargin) nargs = nargin (); ## Add more as needed. opts = __all_db_opts__ (); if (nargs == 0) if (nargout == 0) ## Display possibilities. puts ("\nAll possible optimization options:\n\n"); printf (" %s\n", opts{:}); puts ("\n"); else ## Return struct with all options initialized to [] retval = cell2struct (repmat ({[]}, size (opts)), opts, 2); endif elseif (nargs == 1 && ischar (varargin{1})) ## Return defaults for named function. fcn = varargin{1}; try retval = feval (fcn, "defaults"); catch error ("no defaults for function `%s'", fcn); end_try_catch elseif (nargs == 2 && isstruct (varargin{1}) && isstruct (varargin{2})) ## Set slots in old from nonempties in new. Should we be checking ## to ensure that the field names are expected? old = varargin{1}; new = varargin{2}; fnames = fieldnames (old); ## skip validation if we're in the internal query validation = ! isempty (opts); lopts = tolower (opts); for [val, key] = new if (validation) ## Case insensitive lookup in all options. i = lookup (lopts, tolower (key)); ## Validate option. if (i > 0 && strcmpi (opts{i}, key)) ## Use correct case. key = opts{i}; else warning ("unrecognized option: %s", key); endif endif old.(key) = val; endfor retval = old; elseif (rem (nargs, 2) && isstruct (varargin{1})) ## Set values in old from name/value pairs. pairs = reshape (varargin(2:end), 2, []); retval = setdbopts (varargin{1}, cell2struct (pairs(2, :), pairs(1, :), 2)); elseif (rem (nargs, 2) == 0) ## Create struct. Default values are replaced by those specified by ## name/value pairs. pairs = reshape (varargin, 2, []); retval = setdbopts (struct (), cell2struct (pairs(2, :), pairs(1, :), 2)); else print_usage (); endif endfunction database-2.4.4/inst/PaxHeaders.8241/pq_lo_view.m0000644000000000000000000000013213444726064016251 xustar0030 mtime=1553181748.547524025 30 atime=1553181799.730601974 30 ctime=1553181803.415144792 database-2.4.4/inst/pq_lo_view.m0000644000175000017500000000612213444726064016523 0ustar00olafolaf00000000000000## Copyright (C) 2013-2019 Olaf Till ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} pq_lo_view (@var{connection}, @var{oid}, @var{viewer}) ## ## Exports the large object of Oid @var{oid} in the database associated ## with @var{connection} to a temporary file and starts the program ## @var{viewer} in the background with the name of the temporary file as ## argument. ## ## The temporary file will be removed after termination of the viewer. ## ## @end deftypefn function pq_lo_view (conn, oid, viewer) if (nargin () != 3 || ! ischar (viewer) || rows (viewer) != 1) print_usage (); endif if (([opid, omsg] = fork ()) == 0) ## outer child unwind_protect ## access database in outer child, so parent can't return and ## perform another database access at the same time ## Relying on Octave to delete the tempfile does not work here. if (([~, tname, msg] = mkstemp ... (fullfile (P_tmpdir (), "octave-pq_lo_view-XXXXXX")) ) == -1) error ("could not make temporary file: %s", msg); endif ## We don't use try-catch since it doesn't work if interrupted ## by a signal. But unwind_protect needs to check this flag. vpid = -1; unwind_protect ## throws an error for errors pq_lo_export (conn, oid, tname); if (([vpid, vmsg] = fork ()) == 0) ## child for viewer unwind_protect unwind_protect if (system (sprintf ("%s %s", viewer, tname)) != 0) error ("error in execution of viewer program or viewer terminated by a signal"); endif unwind_protect_cleanup unlink (tname); end_unwind_protect unwind_protect_cleanup __pq_internal_exit__ (); end_unwind_protect elseif (vpid < 0) ## fork for viewer went wrong error ("error in fork for viewer process: %s", vmsg); endif unwind_protect_cleanup ## If no inner child has been forked, delete tempfile here. if (vpid < 0) unlink (tname); endif end_unwind_protect unwind_protect_cleanup __pq_internal_exit__ (); end_unwind_protect elseif (opid < 0) ## fork for outer child went wrong error ("error in fork for outer child: %s", omsg); endif ## parent waitpid (opid); endfunction database-2.4.4/inst/PaxHeaders.8241/pq_exec_params.m0000644000000000000000000000013213444726064017074 xustar0030 mtime=1553181748.547524025 30 atime=1553181799.730601974 30 ctime=1553181803.415144792 database-2.4.4/inst/pq_exec_params.m0000644000175000017500000001415713444726064017355 0ustar00olafolaf00000000000000## Copyright (C) 2013-2019 Olaf Till ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software ## Foundation; either version 3 of the License, or (at your option) any later ## version. ## ## This program is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ## details. ## ## You should have received a copy of the GNU General Public License along with ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} pq_exec_params (@var{connection}, @var{command}) ## @deftypefnx {Loadable Function} pq_exec_params (@var{connection}, @var{command}, @var{params}) ## @deftypefnx {Loadable Function} pq_exec_params (@var{connection}, @var{command}, @var{settings}) ## @deftypefnx {Loadable Function} pq_exec_params (@var{connection}, @var{command}, @var{params}, @var{settings}) ## ## Sends the string @var{command}, which must contain a single SQL ## command, over the connection @var{connection}. Parameters in ## @var{command} can be replaced by $1, $2, etc and their values given ## in the one-dimensional cell-array @var{params}. Parameters of ## composite type sent this way must have their type defined in the ## database. For typeconversions, the package maintains a notion of ## defined types, which should be refreshed with @code{pq_update_types} ## if types are defined or dropped after establishing the connection, or ## if the schema search path changes. @var{settings} is a structure of ## settings, it can be created by @code{setdbopts}. ## ## Settings currently understood by @code{pq_exec_params}: ## ## @table @code ## @item param_types ## One-dimensional cell-array with type specifications for parameters in ## @var{params}. If present, must have the same length as @var{params}. ## Entries may be empty if no specification is necessary (see below). ## Type specifications are strings corresponding to the entries returned ## by @code{SELECT typname FROM pg_type WHERE typarray != 0 OR typtype = ## 'c';}, optionally having @code{[]} appended (without space) to ## indicate an array. Type specifications can be schema-qualified, ## otherwise they refer to the visible type with that name. ## @item copy_in_path, copy_out_path ## Path to files at the client side for @code{copy from stdin} and ## @code{copy to stdout}, respectively. ## @item copy_in_from_variable ## Logical scalar, default @code{false}. If @code{true}, @code{copy from ## stdin} uses data from an Octave variable instead of from a file. ## @item copy_in_data ## 2-dimensional cell-array with columns of suitable type (see below) -- ## will be used instead of a file as data for @code{copy from stdin} if ## @code{copy_in_from_variable} is @code{true}. ## @item copy_in_types ## If some columns in @code{copy_in_data} need a type specification (see ## below), @code{copy_in_types} has to be set to a cell-array with type ## specifications, with an entry (possibly empty) for each column. ## @item copy_in_with_oids ## If you want to copy in with oids when using data from an Octave ## variable, the first column of the data must contain the OIDs and ## @code{copy_in_with_oids} has to be set to @code{true} (default ## @code{false}); @code{with oids} should be specified together with ## @code{copy from stdin} in the command, otherwise Postgresql will ## ignore the copied oids. ## @end table ## ## There is no way to @code{copy to stdout} into an Octave variable, but ## a @code{select} command can be used for this purpose. ## ## @code{copy from stdin} from an Octave variable is only supported in ## binary mode, so this has to be specified in the SQL command. ## ## The output depends on the type of command. ## @itemize ## @item queries (commands potentially returning data): ## The output will be a structure with fields @code{data} (containing ## a cell array with the data, columns correspond to returned database ## columns, rows correspond to returned tuples), @code{columns} ## (containing the column headers), and @code{types} (a ## structure-vector with the postgresql data types of the columns, ## subfields @code{name} (string with typename), @code{is_array} ## (boolean), @code{is_composite} (boolean), @code{is_enum} (boolean), ## and @code{elements} (if @code{is_composite == true}, ## structure-vector of element types, containing fields corresponding ## to those of @code{types})). ## @item copy commands: ## Nothing is returned (this may change in the future). ## @item other commands: ## The output will be the number of affected rows in the database. ## @end itemize ## ## ## @c The following block will be cut out in the package info file. ## @c BEGIN_CUT_TEXINFO ## ## For the mapping of currently implemented Postgresql types to Octave ## types, type @code{database_doc ("Postgresql data types")}. ## ## @c END_CUT_TEXINFO ## ## @seealso {pq_update_types, pq_conninfo} ## @end deftypefn ## PKG_ADD: [~] = __all_db_opts__ ("pq_exec_params"); function ret = pq_exec_params (conn, varargin) ## This wrapper is necessary to work around calling PKG_ADD ## instructions of each added path immediately, before all paths of a ## package are added. In 'pkg install', m-function path is set before ## oct-function path, and left set, so this would work here. But in ## 'pkg build', if the package is not already installed, these paths ## are temporarily and separately set. if ((nargs = nargin) == 0) print_usage (); endif if (nargs == 1 && ischar (conn) && strcmp (conn, "defaults")) ret = setdbopts ("param_types", [], ... "copy_in_path", "", ... "copy_out_path", "", ... "copy_in_data", [], ... "copy_in_with_oids", false, ... "copy_in_types", [], ... "copy_in_from_variable", false); else t_ret = __pq_exec_params__ (conn, varargin{:}); if (! ischar (t_ret)) ## marker for a copy command ret = t_ret; endif endif endfunction database-2.4.4/PaxHeaders.8241/COPYING0000644000000000000000000000013213444726064014005 xustar0030 mtime=1553181748.404724241 30 atime=1553181748.404724241 30 ctime=1553181803.415144792 database-2.4.4/COPYING0000644000175000017500000011114513444726064014261 0ustar00olafolaf00000000000000Appendix G GNU GENERAL PUBLIC LICENSE ************************************* Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. `http://fsf.org/' Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble ======== The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS ==================== 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a. The work must carry prominent notices stating that you modified it, and giving a relevant date. b. The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c. You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d. If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a. Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b. Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c. Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d. Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e. Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a. Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b. Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c. Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d. Limiting the use for publicity purposes of names of licensors or authors of the material; or e. Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f. Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS =========================== How to Apply These Terms to Your New Programs ============================================= If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. Copyright (C) YEAR NAME OF AUTHOR This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see `http://www.gnu.org/licenses/'. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: PROGRAM Copyright (C) YEAR NAME OF AUTHOR This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see `http://www.gnu.org/licenses/'. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read `http://www.gnu.org/philosophy/why-not-lgpl.html'. database-2.4.4/PaxHeaders.8241/INDEX0000644000000000000000000000013213444726064013544 xustar0030 mtime=1553181748.464224151 30 atime=1553181748.464224151 30 ctime=1553181803.415144792 database-2.4.4/INDEX0000644000175000017500000000047313444726064014021 0ustar00olafolaf00000000000000database >> Database. Postgresql connection pq_connect pq_close pq_update_types pq_conninfo Postgresql command execution pq_exec_params Postgresql large objects pq_lo_import pq_lo_export pq_lo_unlink pq_lo_view Documentation database_doc Helpers var2bytea bytea2var Option setting setdbopts getdbopts database-2.4.4/PaxHeaders.8241/Makefile0000644000000000000000000000013213444726064014412 xustar0030 mtime=1553181748.464224151 30 atime=1553181748.464224151 30 ctime=1553181803.415144792 database-2.4.4/Makefile0000644000175000017500000001767413444726064014702 0ustar00olafolaf00000000000000## Copyright 2015-2016 Carnë Draug ## Copyright 2015-2016 Oliver Heimlich ## Copyright 2017 Julien Bect ## Copyright 2017 Olaf Till ## ## Copying and distribution of this file, with or without modification, ## are permitted in any medium without royalty provided the copyright ## notice and this notice are preserved. This file is offered as-is, ## without any warranty. ## Some basic tools (can be overriden using environment variables) SED ?= sed TAR ?= tar GREP ?= grep CUT ?= cut ## Note the use of ':=' (immediate set) and not just '=' (lazy set). ## http://stackoverflow.com/a/448939/1609556 package := $(shell $(GREP) "^Name: " DESCRIPTION | $(CUT) -f2 -d" ") version := $(shell $(GREP) "^Version: " DESCRIPTION | $(CUT) -f2 -d" ") ## This are the paths that will be created for the releases. Using ## $(realpath ...) avoids problems with symlinks. target_dir := $(realpath .)/target release_dir := $(target_dir)/$(package)-$(version) release_tarball := $(target_dir)/$(package)-$(version).tar.gz html_dir := $(target_dir)/$(package)-html html_tarball := $(target_dir)/$(package)-html.tar.gz installation_dir := $(target_dir)/.installation package_list := $(installation_dir)/.octave_packages install_stamp := $(installation_dir)/.install_stamp ## These can be set by environment variables which allow to easily ## test with different Octave versions. ifndef OCTAVE OCTAVE := octave endif OCTAVE := $(OCTAVE) --no-gui --silent --norc MKOCTFILE ?= mkoctfile ## Command used to set permissions before creating tarballs FIX_PERMISSIONS ?= chmod -R a+rX,u+w,go-w,ug-s ## Detect which VCS is used vcs := $(if $(wildcard .hg),hg,$(if $(wildcard .git),git,unknown)) ifeq ($(vcs),hg) release_dir_dep := .hg/dirstate endif ifeq ($(vcs),git) release_dir_dep := .git/index endif ## .PHONY indicates targets that are not filenames ## (https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html) .PHONY: help ## make will display the command before runnning them. Use @command ## to not display it (makes specially sense for echo). help: @echo "Targets:" @echo " dist - Create $(release_tarball) for release." @echo " html - Create $(html_tarball) for release." @echo " release - Create both of the above and show md5sums." @echo " install - Install the package in $(installation_dir), where it is not visible in a normal Octave session." @echo " check - Execute package tests." @echo " doctest - Test the help texts with the doctest package." @echo " run - Run Octave with the package installed in $(installation_dir) in the path." @echo " clean - Remove everything made with this Makefile." ## ## Recipes for release tarballs (package + html) ## .PHONY: release dist html clean-tarballs clean-unpacked-release ## To make a release, build the distribution and html tarballs. release: dist html md5sum $(release_tarball) $(html_tarball) @echo "Upload @ https://sourceforge.net/p/octave/package-releases/new/" @echo " and note the changeset the release corresponds to" ## dist and html targets are only PHONY/alias targets to the release ## and html tarballs. dist: $(release_tarball) html: $(html_tarball) ## An implicit rule with a recipe to build the tarballs correctly. %.tar.gz: % $(TAR) -c -f - --posix -C "$(target_dir)/" "$(notdir $<)" | gzip -9n > "$@" clean-tarballs: @echo "## Cleaning release tarballs (package + html)..." -$(RM) $(release_tarball) $(html_tarball) @echo ## Create the unpacked package. ## ## Notes: ## * having ".hg/dirstate" (or ".git/index") as a prerequesite means it is ## only rebuilt if we are at a different commit. ## * the variable RM usually defaults to "rm -f" ## * having this recipe separate from the one that makes the tarball ## makes it easy to have packages in alternative formats (such as zip) ## * note that if a commands needs to be run in a specific directory, ## the command to "cd" needs to be on the same line. Each line restores ## the original working directory. $(release_dir): $(release_dir_dep) -$(RM) -r "$@" ifeq (${vcs},hg) hg archive --exclude ".hg*" --type files "$@" endif ifeq (${vcs},git) git archive --format=tar --prefix="$@/" HEAD | $(TAR) -x $(RM) "$@/.gitignore" endif ## Don't fall back to run the supposed necessary contents of ## 'bootstrap' here. Users are better off if they provide ## 'bootstrap'. Administrators, checking build reproducibility, can ## put in the missing 'bootstrap' file if they feel they know its ## necessary contents. ifneq (,$(wildcard src/bootstrap)) cd "$@/src" && ./bootstrap && $(RM) -r "autom4te.cache" endif ## Uncomment this if your src/Makefile.in has these targets for ## pre-building something for the release (e.g. documentation). cd "$@/src" && ./configure && $(MAKE) prebuild && \ $(MAKE) distclean && $(RM) Makefile ## ${FIX_PERMISSIONS} "$@" run_in_place = $(OCTAVE) --eval ' pkg ("local_list", "$(package_list)"); ' \ --eval ' pkg ("load", "$(package)"); ' html_options = --eval 'options = get_html_options ("octave-forge");' ## Uncomment this for package documentation. html_options = --eval 'options = get_html_options ("octave-forge");' \ --eval 'options.package_doc = "$(package).texi";' $(html_dir): $(install_stamp) $(RM) -r "$@"; $(run_in_place) \ --eval ' pkg load generate_html; ' \ $(html_options) \ --eval ' generate_package_html ("$(package)", "$@", options); '; $(FIX_PERMISSIONS) "$@"; clean-unpacked-release: @echo "## Cleaning unpacked release tarballs (package + html)..." -$(RM) -r $(release_dir) $(html_dir) @echo ## ## Recipes for installing the package. ## .PHONY: install clean-install octave_install_commands = \ ' llist_path = pkg ("local_list"); \ mkdir ("$(installation_dir)"); \ load (llist_path); \ local_packages(cellfun (@ (x) strcmp ("$(package)", x.name), local_packages)) = []; \ save ("$(package_list)", "local_packages"); \ pkg ("local_list", "$(package_list)"); \ pkg ("prefix", "$(installation_dir)", "$(installation_dir)"); \ pkg ("install", "-local", "-verbose", "$(release_tarball)"); ' ## Install unconditionally. Maybe useful for testing installation with ## different versions of Octave. install: $(release_tarball) @echo "Installing package under $(installation_dir) ..." $(OCTAVE) --eval $(octave_install_commands) touch $(install_stamp) ## Install only if installation (under target/...) is not current. $(install_stamp): $(release_tarball) @echo "Installing package under $(installation_dir) ..." $(OCTAVE) --eval $(octave_install_commands) touch $(install_stamp) clean-install: @echo "## Cleaning installation under $(installation_dir) ..." -$(RM) -r $(installation_dir) @echo ## ## Recipes for testing purposes ## .PHONY: run doctest check ## Start an Octave session with the package directories on the path for ## interactice test of development sources. run: $(install_stamp) $(run_in_place) --persist ## Test example blocks in the documentation. Needs doctest package ## https://octave.sourceforge.io/doctest/index.html doctest: $(install_stamp) $(run_in_place) --eval 'pkg load doctest;' \ --eval "targets = '$(shell (ls inst; ls src | $(GREP) .oct) | $(CUT) -f2 -d@ | $(CUT) -f1 -d.)';" \ --eval "targets = strsplit (targets, ' '); doctest (targets);" ## Test package. octave_test_commands = \ ' args = {"inst", "src"}; \ args(cellfun (@ (x) isempty (a = stat (x)) || ! S_ISDIR (a.mode), args)) = []; \ if (isempty (args)) error ("no \"inst\" or \"src\" directory"); exit (1); \ else cellfun(@runtests, args); endif ' check: $(install_stamp) $(run_in_place) --eval $(octave_test_commands) #--eval '__run_test_suite__ ({"inst", "src"}, {});' ## ## CLEAN ## .PHONY: clean clean: clean-tarballs clean-unpacked-release clean-install @echo "## Removing target directory (if empty)..." -rmdir $(target_dir) @echo @echo "## Cleaning done" @echo database-2.4.4/PaxHeaders.8241/DESCRIPTION0000644000000000000000000000013213444726064014460 xustar0030 mtime=1553181748.436457526 30 atime=1553181802.086987512 30 ctime=1553181803.415144792 database-2.4.4/DESCRIPTION0000644000175000017500000000052113444726064014727 0ustar00olafolaf00000000000000Name: database Version: 2.4.4 Date: 2019-03-13 Author: Olaf Till Maintainer: Olaf Till Title: Database. Description: Interface to SQL databases, currently only postgresql using libpq. Depends: octave (>= 4.0.0), struct (>= 1.0.12) BuildRequires: Postgresql (>= 8.3) Autoload: no License: GPLv3+ database-2.4.4/PaxHeaders.8241/octave-database.metainfo.xml0000644000000000000000000000013213444726064020320 xustar0030 mtime=1553181748.551490686 30 atime=1553181748.551490686 30 ctime=1553181803.415144792 database-2.4.4/octave-database.metainfo.xml0000644000175000017500000000210513444726064020567 0ustar00olafolaf00000000000000 octave-database www.octave.org-octave.desktop Database SQL database access

Interface to SQL databases, currently only postgresql using libpq.

database SQL postgresql http://octave.sourceforge.net/database https://savannah.gnu.org/bugs/?func=additem&group=octave GPL-3.0+ Octave-Forge Community octave-maintainers@gnu.org FSFAP
database-2.4.4/PaxHeaders.8241/doc0000644000000000000000000000013213444726153013441 xustar0030 mtime=1553181803.015103333 30 atime=1553181803.415144792 30 ctime=1553181803.415144792 database-2.4.4/doc/0000755000175000017500000000000013444726153013767 5ustar00olafolaf00000000000000database-2.4.4/doc/PaxHeaders.8241/html0000644000000000000000000000013213444726153014405 xustar0030 mtime=1553181803.391142305 30 atime=1553181803.415144792 30 ctime=1553181803.415144792 database-2.4.4/doc/html/0000755000175000017500000000000013444726153014733 5ustar00olafolaf00000000000000database-2.4.4/doc/html/PaxHeaders.8241/Postgresql.html0000644000000000000000000000013213444726153017513 xustar0030 mtime=1553181803.251127795 30 atime=1553181803.247127381 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Postgresql.html0000644000175000017500000001052513444726153017767 0ustar00olafolaf00000000000000 database_doc: Postgresql

Next: , Previous: , Up: Top   [Index]


7 Description of access to Postgresql databases

database-2.4.4/doc/html/PaxHeaders.8241/XREFpq_005flo_005fexport.html0000644000000000000000000000013213444726153021536 xustar0030 mtime=1553181803.379141061 30 atime=1553181803.379141061 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFpq_005flo_005fexport.html0000644000175000017500000000511213444726153022006 0ustar00olafolaf00000000000000 database_doc: XREFpq_lo_export

The node you are looking for is at XREFpq_lo_export.

database-2.4.4/doc/html/PaxHeaders.8241/Connection-functions.html0000644000000000000000000000013213444726153021455 xustar0030 mtime=1553181803.267129454 30 atime=1553181803.263129039 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Connection-functions.html0000644000175000017500000001014613444726153021730 0ustar00olafolaf00000000000000 database_doc: Connection functions

7.2 Functions related to the connection to a Postgresql database

database-2.4.4/doc/html/PaxHeaders.8241/XREFpq_005fconninfo.html0000644000000000000000000000013213444726153020741 xustar0030 mtime=1553181803.379141061 30 atime=1553181803.379141061 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFpq_005fconninfo.html0000644000175000017500000000506213444726153021215 0ustar00olafolaf00000000000000 database_doc: XREFpq_conninfo

The node you are looking for is at XREFpq_conninfo.

database-2.4.4/doc/html/PaxHeaders.8241/XREFvar2bytea.html0000644000000000000000000000013213444726153017734 xustar0030 mtime=1553181803.391142305 30 atime=1553181803.391142305 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFvar2bytea.html0000644000175000017500000000502213444726153020204 0ustar00olafolaf00000000000000 database_doc: XREFvar2bytea

The node you are looking for is at XREFvar2bytea.

database-2.4.4/doc/html/PaxHeaders.8241/pq_005flo_005fexport.html0000644000000000000000000000013213444726153021051 xustar0030 mtime=1553181803.327135672 30 atime=1553181803.323135257 30 ctime=1553181803.415144792 database-2.4.4/doc/html/pq_005flo_005fexport.html0000644000175000017500000000744513444726153021334 0ustar00olafolaf00000000000000 database_doc: pq_lo_export

Next: , Previous: , Up: Data exchange   [Index]


7.3.4 Exporting large objects from a database

Loadable Function: pq_lo_export (connection, oid, path)

Exports the large object of Oid oid in the database associated with connection to the file path on the client side. If path starts with a |, it is taken as a shell commant to pipe to.

database-2.4.4/doc/html/PaxHeaders.8241/XREFpq_005flo_005fview.html0000644000000000000000000000013013444726153021165 xustar0029 mtime=1553181803.38714189 29 atime=1553181803.38714189 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFpq_005flo_005fview.html0000644000175000017500000000507213444726153021444 0ustar00olafolaf00000000000000 database_doc: XREFpq_lo_view

The node you are looking for is at XREFpq_lo_view.

database-2.4.4/doc/html/PaxHeaders.8241/var2bytea.html0000644000000000000000000000013213444726153017247 xustar0030 mtime=1553181803.199122406 30 atime=1553181803.191121577 30 ctime=1553181803.415144792 database-2.4.4/doc/html/var2bytea.html0000644000175000017500000001050413444726153017520 0ustar00olafolaf00000000000000 database_doc: var2bytea

4.1 Converting Octave variables to bytea

Loadable Function: var2bytea (value, …)

Save input values in uint8 arrays in Octaves binary save format.

This function returns as many output variables as input variables are given.

The function can be used to prepare storage of Octave variable values as binary strings in a database, if the variables types have no corresponding SQL type. Each variable type which can be correctly saved and loaded with Octaves save and load functions is acceptable. The variable value can be restored with the function bytea2var.

Note that the inputs are not variable names, but values. No variable names are saved. Loading the uint8 array with load (possibly after dumping it to a file) will not work.

Example: to convert the first and third column of a cell-array c, [c{:, [1, 3]}] = var2bytea (c{:, [1, 3]}); can be used.

See also: bytea2var.

database-2.4.4/doc/html/PaxHeaders.8241/Large-objects.html0000644000000000000000000000013113444726153020030 xustar0030 mtime=1553181803.347137745 29 atime=1553181803.34313733 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Large-objects.html0000644000175000017500000001061413444726153020304 0ustar00olafolaf00000000000000 database_doc: Large objects

Next: , Up: Examples   [Index]


7.4.1 Large objects


# connect
conn = pq_connect (setdbopts ("dbname", "test"));

# create table to store large object oids
pq_exec_params (conn, "create table programs (name text, image oid);")

# start transaction, so we don't miss storing the oid
pq_exec_params (conn, "begin;")

# download image, pipe it to a large objects and note its oid
# (you need `wget' to be installed)
oid = pq_lo_import (conn,
"wget -q -O - https://www.gnu.org/software/octave/img/example-mesh.svg |")

# write oid and program name into the table
pq_exec_params (conn,
                "insert into programs values ($1, $2);", {"Octave", oid})

# finish transaction
pq_exec_params (conn, "commit;")

# find and retrieve the oid searching for the program name
foid = pq_exec_params (conn,
                       "select image from programs where name = $1;",
                       {"Octave"}).data{1}

# view large object corresponding to found foid
# (you need `eog' to be installed, or change to another program able to
# display `.svg')
pq_lo_view (conn, foid, "eog")

# cleanup (we don't use `begin;' and `rollback;' since the
# example should show an inner transaction instead)

pq_lo_unlink (conn, oid);

pq_exec_params (conn, "drop table programs;");

pq_close (conn);

database-2.4.4/doc/html/PaxHeaders.8241/XREFsetdbopts.html0000644000000000000000000000013113444726153020043 xustar0030 mtime=1553181803.391142305 29 atime=1553181803.38714189 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFsetdbopts.html0000644000175000017500000000502213444726153020314 0ustar00olafolaf00000000000000 database_doc: XREFsetdbopts

The node you are looking for is at XREFsetdbopts.

database-2.4.4/doc/html/PaxHeaders.8241/getdbopts.html0000644000000000000000000000013213444726153017343 xustar0030 mtime=1553181803.239126552 30 atime=1553181803.227125308 30 ctime=1553181803.415144792 database-2.4.4/doc/html/getdbopts.html0000644000175000017500000000765013444726153017624 0ustar00olafolaf00000000000000 database_doc: getdbopts

Previous: , Up: Setting options   [Index]


5.2 Function getdbopts for retrieving options in ’database’

This function is internally called by the functions of ’database’.

Function File: getdbopts (options, parname)
Function File: getdbopts (options, parname, default)

Return a specific setting from a structure created by setdbopts. If parname is not a field of the options structure, return default if supplied, otherwise return an empty matrix.

(This function uses the code of Octaves ’optimget’ function.)

database-2.4.4/doc/html/PaxHeaders.8241/Data-exchange.html0000644000000000000000000000013213444726153020001 xustar0030 mtime=1553181803.291131941 30 atime=1553181803.287131526 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Data-exchange.html0000644000175000017500000001146713444726153020263 0ustar00olafolaf00000000000000 database_doc: Data exchange

Next: , Previous: , Up: Postgresql   [Index]


7.3 Functions for data exchange with a Postgresql database

database-2.4.4/doc/html/PaxHeaders.8241/Arbitrary-Octave-types.html0000644000000000000000000000013213444726153021670 xustar0030 mtime=1553181803.191121577 30 atime=1553181803.183120748 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Arbitrary-Octave-types.html0000644000175000017500000001034013444726153022137 0ustar00olafolaf00000000000000 database_doc: Arbitrary Octave types

Next: , Previous: , Up: Top   [Index]


4 Storing arbitrary Octave types in a database

If Octave variable types have corresponding SQL types ( see SQL data types , also consider the links there to types specific for database implementations), the variables can directly be stored in a database. If not, the variables can be converted to representations of the SQL type bytea and then stored. This way of storing is possible for all Octave types which can be correctly saved and loaded with Octaves save and load functions.

database-2.4.4/doc/html/PaxHeaders.8241/pq_005flo_005funlink.html0000644000000000000000000000013213444726153021030 xustar0030 mtime=1553181803.335136501 30 atime=1553181803.327135672 30 ctime=1553181803.415144792 database-2.4.4/doc/html/pq_005flo_005funlink.html0000644000175000017500000000717513444726153021313 0ustar00olafolaf00000000000000 database_doc: pq_lo_unlink

Next: , Previous: , Up: Data exchange   [Index]


7.3.5 Deleting large objects from a database

Loadable Function: pq_lo_unlink (connection, oid)

Removes the large object of Oid oid from the database associated with connection.

database-2.4.4/doc/html/PaxHeaders.8241/pq_005flo_005fimport.html0000644000000000000000000000013213444726153021042 xustar0030 mtime=1553181803.323135257 30 atime=1553181803.319134843 30 ctime=1553181803.415144792 database-2.4.4/doc/html/pq_005flo_005fimport.html0000644000175000017500000000755513444726153021327 0ustar00olafolaf00000000000000 database_doc: pq_lo_import

Next: , Previous: , Up: Data exchange   [Index]


7.3.3 Importing large objects into a database

Loadable Function: oid = pq_lo_import (connection, path)

Imports the file in path on the client side as a large object into the database associated with connection and returns the Oid of the new large object. If path ends with a |, it is take as a shell command whose output is piped into a large object.

database-2.4.4/doc/html/PaxHeaders.8241/Composite-types.html0000644000000000000000000000013213444726153020454 xustar0030 mtime=1553181803.359138989 30 atime=1553181803.351138159 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Composite-types.html0000644000175000017500000001350313444726153020727 0ustar00olafolaf00000000000000 database_doc: Composite types

Previous: , Up: Examples   [Index]


7.4.3 Working with composite types

This is a more complicated example with nested composite types.


# connect
conn = pq_connect (setdbopts ("dbname", "test"));

# create a first composite type, consisting of a boolean and an array of
# booleans
pq_exec_params (conn,
"create type complex_bool_array_type as (b bool, ba bool[]);")

# create a second composite type, consisting of a boolean and the first
# composite type
pq_exec_params (conn,
"create type complex_complex_bool_array_type as (b bool, c complex_bool_array_type);")

# create a table with one column, holding the second defined composite
# type
pq_exec_params (conn,
"create table complex_complex_bool_array (a complex_complex_bool_array_type);")

# to enable data exchange using the new types, update type infomation
pq_update_types (conn);

# construct a data element for an SQL array of booleans in Octave
d_arr = cell2struct ({2; {true, false; true, true}}, {"ndims", "data"})

# construct a data element for the first defined composite type in
# Octave
d_c1 = {true; d_arr};

# construct a data element for the second defined composite type in
# Octave
d_c2 = {false; d_c1};

# insert the data element of the second composite type into the table;
# note that in this case specification of the parameter type in
# `param_types' is necessary
pq_exec_params (conn,
                "insert into complex_complex_bool_array values ($1);",
                {d_c2},
                setdbopts ("param_types", {"complex_complex_bool_array_type"}))

# read contents of the table
result = pq_exec_params (conn, "select * from complex_complex_bool_array");



# only for demonstration purpouses, verify that the read data matches
# the element constructed in Octave;
# for this, the field `lbounds' is deleted from the returned data
#
# note that the verification would not work if we had constructed the
# data element with rows of cell-arrays instead of columns, which would
# also have been possible
rdata = result.data{1};
rdata{2}{2} = rmfield (rdata{2}{2}, "lbounds");
isequal (d_c2, rdata)

# view returned column names
result.columns

# view returned type information
result.types

# cleanup

pq_exec_params (conn, "drop table complex_complex_bool_array;")

pq_exec_params (conn, "drop type complex_complex_bool_array_type;")

pq_exec_params (conn, "drop type complex_bool_array_type;")

pq_close (conn);


Previous: , Up: Examples   [Index]

database-2.4.4/doc/html/PaxHeaders.8241/Copy-in.html0000644000000000000000000000013213444726153016666 xustar0030 mtime=1553181803.351138159 30 atime=1553181803.347137745 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Copy-in.html0000644000175000017500000001001313444726153017132 0ustar00olafolaf00000000000000 database_doc: Copy in

Next: , Previous: , Up: Examples   [Index]


7.4.2 Copy in from Octave variable


# connect
conn = pq_connect (setdbopts ("dbname", "test"));

# create table
pq_exec_params (conn,
                "create table testdata (a float8, b float8, label text);")

# generate data in Octave
data = horzcat (num2cell (reshape (linspace (3, 4, 10), [], 2)),
                {"a"; "b"; "c"; "d"; "e"})

# copy in to the table
pq_exec_params (conn, "copy testdata from stdin with (format binary);",
                setdbopts ("copy_in_from_variable", true,
                           "copy_in_data", data))

# retrieve the data from the table
rdata = pq_exec_params (conn, "select * from testdata;").data

# cleanup 

pq_exec_params (conn, "drop table testdata;");

pq_close (conn);

database-2.4.4/doc/html/PaxHeaders.8241/XREFdatabase_005fdoc.html0000644000000000000000000000013213444726153021021 xustar0030 mtime=1553181803.371140232 30 atime=1553181803.371140232 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFdatabase_005fdoc.html0000644000175000017500000000506413444726153021277 0ustar00olafolaf00000000000000 database_doc: XREFdatabase_doc

The node you are looking for is at XREFdatabase_doc.

database-2.4.4/doc/html/PaxHeaders.8241/Concept-index.html0000644000000000000000000000013213444726153020050 xustar0030 mtime=1553181803.367139818 30 atime=1553181803.363139403 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Concept-index.html0000644000175000017500000001535413444726153020331 0ustar00olafolaf00000000000000 database_doc: Concept index

Previous: , Up: Top   [Index]


Concept index

Jump to:   A   D   E   O   P  
Index Entry  Section

A
arbitrary Octave types: Arbitrary Octave types

D
data exchange, Postgresql: Data exchange
data types: SQL data types
data types: Postgresql data types
database connection: Connection functions
documentation: Documentation

E
examples, postgresql: Examples

O
options: Setting options

P
postgresql: Postgresql
postgresql examples: Examples

Jump to:   A   D   E   O   P  
database-2.4.4/doc/html/PaxHeaders.8241/pq_005fclose.html0000644000000000000000000000013213444726153017550 xustar0030 mtime=1553181803.283131112 30 atime=1553181803.275130283 30 ctime=1553181803.415144792 database-2.4.4/doc/html/pq_005fclose.html0000644000175000017500000000717613444726153020034 0ustar00olafolaf00000000000000 database_doc: pq_close

Next: , Previous: , Up: Connection functions   [Index]


7.2.2 Disconnecting from a Postgresql database

Loadable Function: pq_close (connection)

Closes connection connection to a postgresql server.

See also: pq_connect.

database-2.4.4/doc/html/PaxHeaders.8241/Concept.html0000644000000000000000000000013113444726153016742 xustar0029 mtime=1553181803.15911826 30 atime=1553181803.151117431 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Concept.html0000644000175000017500000001132213444726153017213 0ustar00olafolaf00000000000000 database_doc: Concept

Next: , Previous: , Up: Top   [Index]


2 Introduction and package concept

To enable scripting of SQL access, particularly combinations of SQL commands with temporary local storage or local processing of data, for almost each SQL data type a corresponding representation of the data in Octave is defined. This includes the SQL array types and user-defined SQL composite types (row types) of arbitrary nesting depth. Octave variables containing these corresponding representations are created by the package if data is received from a database by a select query, and correspondingly are used for sending data to the database. This data exchange is lossless if the database backend allows it (which is the case for Postgresql).

The representations of SQL types in Octave are the ’naturally’ corresponding Octave types, if possible. They can also be created directly in Octave and sent to a database.

The package keeps a notion of all SQL types available in a database. This information is automatically retrieved after connecting. If the user creates new types with SQL commands, a package function for refreshing the packages information on types must be called for the type to be available within the same session. The same function should be called if the session continues after deletion of types.

The package provides functions for issuing SQL commands whose text is provided by the user. The command text can contain placeholders for data. The data, corresponding to these placeholders, can be passed to the function in separate arguments.

In queries, not only data is returned, but also information on data type and column names.

database-2.4.4/doc/html/PaxHeaders.8241/Setting-options.html0000644000000000000000000000013213444726153020456 xustar0030 mtime=1553181803.215124064 30 atime=1553181803.207123235 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Setting-options.html0000644000175000017500000000737513444726153020743 0ustar00olafolaf00000000000000 database_doc: Setting options

Next: , Previous: , Up: Top   [Index]


5 Functions for setting or retrieving options

Some functions in ’database’ accept options. These are set or retrieved with the following functions.

database-2.4.4/doc/html/PaxHeaders.8241/pq_005flo_005fview.html0000644000000000000000000000013213444726153020502 xustar0030 mtime=1553181803.339136916 30 atime=1553181803.335136501 30 ctime=1553181803.415144792 database-2.4.4/doc/html/pq_005flo_005fview.html0000644000175000017500000000725413444726153020763 0ustar00olafolaf00000000000000 database_doc: pq_lo_view

Previous: , Up: Data exchange   [Index]


7.3.6 Viewing large objects

Function File: pq_lo_view (connection, oid, viewer)

Exports the large object of Oid oid in the database associated with connection to a temporary file and starts the program viewer in the background with the name of the temporary file as argument.

The temporary file will be removed after termination of the viewer.

database-2.4.4/doc/html/PaxHeaders.8241/XREFgetdbopts.html0000644000000000000000000000013213444726153020030 xustar0030 mtime=1553181803.371140232 30 atime=1553181803.371140232 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFgetdbopts.html0000644000175000017500000000502213444726153020300 0ustar00olafolaf00000000000000 database_doc: XREFgetdbopts

The node you are looking for is at XREFgetdbopts.

database-2.4.4/doc/html/PaxHeaders.8241/index.html0000644000000000000000000000013213444726153016457 xustar0030 mtime=1553181803.143116602 30 atime=1553181803.039105823 30 ctime=1553181803.415144792 database-2.4.4/doc/html/index.html0000644000175000017500000001510513444726153016732 0ustar00olafolaf00000000000000 database_doc: Top

database_doc

Next: , Up: (dir)   [Index]


General documentation for the database package for Octave

The info version of this document is accessible, after package installation, from the Octave commandline with database_doc().

This documentation applies to version 2.4.4 of the database package.

The database package enables accessing SQL databases from Octave. Differences between database implementations will inevitably cause some of this packages functions to be specific for a certain implementation. Currently, however, this package only supports the Postgresql database. Later additions might support further databases, and possibly some general functions (with only very basic functionality), which can be used for all backends, will also be provided.

This documentation currently describes the concepts of SQL access in ’database’ and the details for Postgresql. Familiarity with SQL and the database implementation (Postgresql) is assumed.


Next: , Up: (dir)   [Index]

database-2.4.4/doc/html/PaxHeaders.8241/pq_005fconnect.html0000644000000000000000000000013213444726153020074 xustar0030 mtime=1553181803.275130283 30 atime=1553181803.267129454 30 ctime=1553181803.415144792 database-2.4.4/doc/html/pq_005fconnect.html0000644000175000017500000001300513444726153020344 0ustar00olafolaf00000000000000 database_doc: pq_connect

7.2.1 Connecting to a Postgresql database

Function File: connection = pq_connect (settings)

Establishes a connection to a postgresql server according to settings and returns an octave_pq_connection object connection which can be passed to other functions of the package. There can be multiple connections. An octave_pq_connection object contains information on a connection and will be internally altered by the packages functions even though it is only passed as an argument, i.e. Octaves ’pass by value’ semantics are not adhered to in this case.

settings can be set by setdbopts (copied from Octaves optimset) and can contain (defaults depend on Postgresql): host (hostname), hostaddr (numeric host address), port (port to connect to), dbname (database to connect to), user (user name to connect as), password, connect_timeout, options (command-line options to send to the server at run-time, see Postgresql documentation), sslmode (disable, allow, prefer, require, verify-ca, or verify-full; see Postgresql documentation of SSL support), sslcert (file name of client SSL certificate), sslkey (location of secret key for client certificate, file name or external OpenSSL engine (colon-separated engine name and an engine-specific key identifier)), sslrootcert (file name of root SSL certificate), sslcrl (file name of SSL certificate revocation list), krbsrvname (kerberos service name), service (service name in pq_service.conf to use for additional parameters).

All these settings are passed to the server as they are, so it may be better to consult the postgresql documentation for them, e.g. the documentation of the PQconnectdb function in libpq.

See also: pq_exec_params, pq_update_types.

database-2.4.4/doc/html/PaxHeaders.8241/pq_005fupdate_005ftypes.html0000644000000000000000000000013213444726153021544 xustar0030 mtime=1553181803.319134843 30 atime=1553181803.311134014 30 ctime=1553181803.415144792 database-2.4.4/doc/html/pq_005fupdate_005ftypes.html0000644000175000017500000000753013444726153022022 0ustar00olafolaf00000000000000 database_doc: pq_update_types

Next: , Previous: , Up: Data exchange   [Index]


7.3.2 Updating type information

Loadable Function: pq_update_types (connection)

Updates information on existing postgresql types for connection. Use this before pq_exec_params if types were created or dropped while the connection was already established or if the schema search path changed. A newly created connection will automatically retrieve this information at connection time.

database-2.4.4/doc/html/PaxHeaders.8241/XREFbytea2var.html0000644000000000000000000000013213444726153017734 xustar0030 mtime=1553181803.371140232 30 atime=1553181803.371140232 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFbytea2var.html0000644000175000017500000000502213444726153020204 0ustar00olafolaf00000000000000 database_doc: XREFbytea2var

The node you are looking for is at XREFbytea2var.

database-2.4.4/doc/html/PaxHeaders.8241/XREFpq_005fconnect.html0000644000000000000000000000013213444726153020561 xustar0030 mtime=1553181803.375140647 30 atime=1553181803.375140647 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFpq_005fconnect.html0000644000175000017500000000505213444726153021034 0ustar00olafolaf00000000000000 database_doc: XREFpq_connect

The node you are looking for is at XREFpq_connect.

database-2.4.4/doc/html/PaxHeaders.8241/XREFpq_005flo_005fimport.html0000644000000000000000000000013213444726153021527 xustar0030 mtime=1553181803.383141476 30 atime=1553181803.383141476 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFpq_005flo_005fimport.html0000644000175000017500000000511213444726153021777 0ustar00olafolaf00000000000000 database_doc: XREFpq_lo_import

The node you are looking for is at XREFpq_lo_import.

database-2.4.4/doc/html/PaxHeaders.8241/XREFpq_005fexec_005fparams.html0000644000000000000000000000013213444726153022012 xustar0030 mtime=1553181803.379141061 30 atime=1553181803.379141061 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFpq_005fexec_005fparams.html0000644000175000017500000000513213444726153022264 0ustar00olafolaf00000000000000 database_doc: XREFpq_exec_params

The node you are looking for is at XREFpq_exec_params.

database-2.4.4/doc/html/PaxHeaders.8241/Function-index.html0000644000000000000000000000013213444726153020242 xustar0030 mtime=1553181803.363139403 30 atime=1553181803.359138989 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Function-index.html0000644000175000017500000002022413444726153020513 0ustar00olafolaf00000000000000 database_doc: Function index

Next: , Previous: , Up: Top   [Index]


Index of functions in database

Jump to:   B   D   G   P   S   V  
Index Entry  Section

B
bytea2var: bytea2var

D
database_doc: Documentation

G
getdbopts: getdbopts

P
pq_close: pq_close
pq_connect: pq_connect
pq_conninfo: pq_conninfo
pq_exec_params: pq_exec_params
pq_lo_export: pq_lo_export
pq_lo_import: pq_lo_import
pq_lo_unlink: pq_lo_unlink
pq_lo_view: pq_lo_view
pq_update_types: pq_update_types

S
setdbopts: setdbopts

V
var2bytea: var2bytea

Jump to:   B   D   G   P   S   V  
database-2.4.4/doc/html/PaxHeaders.8241/pq_005fexec_005fparams.html0000644000000000000000000000013213444726153021325 xustar0030 mtime=1553181803.311134014 30 atime=1553181803.291131941 30 ctime=1553181803.415144792 database-2.4.4/doc/html/pq_005fexec_005fparams.html0000644000175000017500000002113313444726153021576 0ustar00olafolaf00000000000000 database_doc: pq_exec_params

7.3.1 Issuing SQL commands

Function File: pq_exec_params (connection, command)
Loadable Function: pq_exec_params (connection, command, params)
Loadable Function: pq_exec_params (connection, command, settings)
Loadable Function: pq_exec_params (connection, command, params, settings)

Sends the string command, which must contain a single SQL command, over the connection connection. Parameters in command can be replaced by $1, $2, etc and their values given in the one-dimensional cell-array params. Parameters of composite type sent this way must have their type defined in the database. For typeconversions, the package maintains a notion of defined types, which should be refreshed with pq_update_types if types are defined or dropped after establishing the connection, or if the schema search path changes. settings is a structure of settings, it can be created by setdbopts.

Settings currently understood by pq_exec_params:

param_types

One-dimensional cell-array with type specifications for parameters in params. If present, must have the same length as params. Entries may be empty if no specification is necessary (see below). Type specifications are strings corresponding to the entries returned by SELECT typname FROM pg_type WHERE typarray != 0 OR typtype = 'c';, optionally having [] appended (without space) to indicate an array. Type specifications can be schema-qualified, otherwise they refer to the visible type with that name.

copy_in_path, copy_out_path

Path to files at the client side for copy from stdin and copy to stdout, respectively.

copy_in_from_variable

Logical scalar, default false. If true, copy from stdin uses data from an Octave variable instead of from a file.

copy_in_data

2-dimensional cell-array with columns of suitable type (see below) – will be used instead of a file as data for copy from stdin if copy_in_from_variable is true.

copy_in_types

If some columns in copy_in_data need a type specification (see below), copy_in_types has to be set to a cell-array with type specifications, with an entry (possibly empty) for each column.

copy_in_with_oids

If you want to copy in with oids when using data from an Octave variable, the first column of the data must contain the OIDs and copy_in_with_oids has to be set to true (default false); with oids should be specified together with copy from stdin in the command, otherwise Postgresql will ignore the copied oids.

There is no way to copy to stdout into an Octave variable, but a select command can be used for this purpose.

copy from stdin from an Octave variable is only supported in binary mode, so this has to be specified in the SQL command.

The output depends on the type of command.

  • queries (commands potentially returning data): The output will be a structure with fields data (containing a cell array with the data, columns correspond to returned database columns, rows correspond to returned tuples), columns (containing the column headers), and types (a structure-vector with the postgresql data types of the columns, subfields name (string with typename), is_array (boolean), is_composite (boolean), is_enum (boolean), and elements (if is_composite == true, structure-vector of element types, containing fields corresponding to those of types)).
  • copy commands: Nothing is returned (this may change in the future).
  • other commands: The output will be the number of affected rows in the database.

See also: pq_update_types, pq_conninfo.

Type mapping

For the mapping of currently implemented Postgresql types to Octave types, see Postgresql data types.


database-2.4.4/doc/html/PaxHeaders.8241/XREFpq_005flo_005funlink.html0000644000000000000000000000013213444726153021515 xustar0030 mtime=1553181803.383141476 30 atime=1553181803.383141476 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFpq_005flo_005funlink.html0000644000175000017500000000511213444726153021765 0ustar00olafolaf00000000000000 database_doc: XREFpq_lo_unlink

The node you are looking for is at XREFpq_lo_unlink.

database-2.4.4/doc/html/PaxHeaders.8241/XREFpq_005fupdate_005ftypes.html0000644000000000000000000000013013444726153022227 xustar0029 mtime=1553181803.38714189 29 atime=1553181803.38714189 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFpq_005fupdate_005ftypes.html0000644000175000017500000000514213444726153022504 0ustar00olafolaf00000000000000 database_doc: XREFpq_update_types

The node you are looking for is at XREFpq_update_types.

database-2.4.4/doc/html/PaxHeaders.8241/bytea2var.html0000644000000000000000000000013213444726153017247 xustar0030 mtime=1553181803.207123235 30 atime=1553181803.199122406 30 ctime=1553181803.415144792 database-2.4.4/doc/html/bytea2var.html0000644000175000017500000000714513444726153017527 0ustar00olafolaf00000000000000 database_doc: bytea2var

Previous: , Up: Arbitrary Octave types   [Index]


4.2 Converting bytea back to Octave variables

Loadable Function: bytea2var (value, …)

Restore variable values from uint8 arrays generated with var2bytea.

Returns as many output variables as input variables are given.

See also: var2bytea.

database-2.4.4/doc/html/PaxHeaders.8241/Postgresql-data-types.html0000644000000000000000000000013213444726153021564 xustar0030 mtime=1553181803.263129039 30 atime=1553181803.251127795 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Postgresql-data-types.html0000644000175000017500000001522213444726153022037 0ustar00olafolaf00000000000000 database_doc: Postgresql data types

7.1 Representation in Octave of types specific to Postgresql

For the general types, defined by SQL and potentially available in each database implementation, see SQL data types.

The last column indicates whether the SQL type is automatically deduced by this packages functions from the representation of the data in Octave. If not, the correct SQL type must be specified by the user if the data is sent from Octave to the database.

PostgresqlOctaveauto
oiduint32 scalaryes
textstringyes
namestring of length < NAMEDATALEN (often 64)no
moneyint64 scalar, which is 100 times the currency value to enable storing the ’small currency’ (e.g. Cent) fraction in the last two digitsno
pointgeometric point data for one point (see below)yes
lseggeometric point data for two points (see below)yes
line (not yet implemented by postgresql-9.2.4)as lsegno
boxas lsegno
circlereal vector (but the restrictions for type uint8 as in geometric element type apply, as explained below) with 3 elements, no. 1 and 2 centre coordinates, no. 3 radiusyes
polygongeometric point data (see below)no
pathstructure with fields closed (boolean, is path closed?) and path (geometric point data, see below).no
inetuint8 array of 4 or 5 elements for IPv4 or uint16 array of 8 or 9 elements for IPv6. 5th or 9th element, respectively, contain number of set bits in network mask, the default (if there are only 4 or 8 elements, respectively) is all bits set.no
cidras inetno
macaddruint8 array of 6 elementsno
uuiduint8 array of 16 elementsno
any enum typestringno

The 8-byte-time value (see time types in SQL data types) can be an int64 scalar, representing microseconds, if the Postgresql server is configured for integer date/time, or a double scalar, representing seconds, if the server is configured for float date/time (deprecated). One can use pq_conninfo to query the respective server configuration.

Geometric point data: if converting from Octave data, any real array (but if of type uint8, the geometric type name must always be specified, for otherwise uint8 would be considered as bytea) with even number of elements. Two adjacent elements (adjacent if indexed with a single index) define a pair of 2D point coordinates. In converting from Postgresql data, dimensions of Octave geometric point data will be chosen to be (2, n_points) and elements will be of format double.


database-2.4.4/doc/html/PaxHeaders.8241/Installation.html0000644000000000000000000000013213444726153020011 xustar0030 mtime=1553181803.151117431 30 atime=1553181803.143116602 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Installation.html0000644000175000017500000000731713444726153020272 0ustar00olafolaf00000000000000 database_doc: Installation

Next: , Previous: , Up: Top   [Index]


1 Installation hints

Maybe your distribution provides the database package.

If not, or if you want a newer version, Octaves pkg command allows building the package from source and installing it. Note that you have to load any Octave package before you can use it. See Octaves documentation of pkg.

In building from source with pkg, some preconditions of the system are checked, in particular the presence of the pq library of Postgresql. If you have to install a package of your operating system with libpq, you usually also need to install the so called development package (named libpq-dev or similar).

database-2.4.4/doc/html/PaxHeaders.8241/XREFpq_005fclose.html0000644000000000000000000000013213444726153020235 xustar0030 mtime=1553181803.375140647 30 atime=1553181803.375140647 30 ctime=1553181803.415144792 database-2.4.4/doc/html/XREFpq_005fclose.html0000644000175000017500000000503213444726153020506 0ustar00olafolaf00000000000000 database_doc: XREFpq_close

The node you are looking for is at XREFpq_close.

database-2.4.4/doc/html/PaxHeaders.8241/pq_005fconninfo.html0000644000000000000000000000013213444726153020254 xustar0030 mtime=1553181803.287131526 30 atime=1553181803.283131112 30 ctime=1553181803.415144792 database-2.4.4/doc/html/pq_005fconninfo.html0000644000175000017500000000773613444726153020542 0ustar00olafolaf00000000000000 database_doc: pq_conninfo

Previous: , Up: Connection functions   [Index]


7.2.3 Retrieving information on the connection and on the server

Loadable Function: val = pq_conninfo (connection, label)

Retrieves connection information for postgresql connection connection, specified by the string label, and returns the value of this information in val. The type of val depends on the requested information. Currently, the only recognized label is 'integer_datetimes'; val is true if 8-byte date and time values are stored as integer in the server, and false if they are stored as double (which is deprecated).

database-2.4.4/doc/html/PaxHeaders.8241/setdbopts.html0000644000000000000000000000013213444726153017357 xustar0030 mtime=1553181803.227125308 30 atime=1553181803.215124064 30 ctime=1553181803.415144792 database-2.4.4/doc/html/setdbopts.html0000644000175000017500000001105213444726153017627 0ustar00olafolaf00000000000000 database_doc: setdbopts

Next: , Up: Setting options   [Index]


5.1 Function setdbopts for setting options in ’database’

Function File: setdbopts ()
Function File: setdbopts (par, val, …)
Function File: setdbopts (old, par, val, …)
Function File: setdbopts (old, new)

Create settings structure for database functions.

When called without any input or output arguments, ’setdbopts’ prints a list of all valid optimization parameters.

When called with one output and no inputs, return an options structure with all valid option parameters initialized to ’[]’.

When called with a list of parameter/value pairs, return an options structure with only the named parameters initialized.

When the first input is an existing options structure OLD, the values are updated from either the PAR/VAL list or from the options structure NEW.

Please see individual database functions for valid settings.

(Most of this documentation and this functions code are copied from Octaves ’optimset’ function.)

database-2.4.4/doc/html/PaxHeaders.8241/Documentation.html0000644000000000000000000000013213444726153020161 xustar0030 mtime=1553181803.247127381 30 atime=1553181803.239126552 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Documentation.html0000644000175000017500000000751613444726153020443 0ustar00olafolaf00000000000000 database_doc: Documentation

Next: , Previous: , Up: Top   [Index]


6 Function database_doc to view documentation

Function File: database_doc ()
Function File: database_doc (keyword)

Show database package documentation.

Runs the info viewer Octave is configured with on the documentation in info format of the installed database package. Without argument, the top node of the documentation is displayed. With an argument, the respective index entry is searched for and its node displayed.

database-2.4.4/doc/html/PaxHeaders.8241/Examples.html0000644000000000000000000000013113444726153017125 xustar0029 mtime=1553181803.34313733 30 atime=1553181803.339136916 30 ctime=1553181803.415144792 database-2.4.4/doc/html/Examples.html0000644000175000017500000001131313444726153017376 0ustar00olafolaf00000000000000 database_doc: Examples

Previous: , Up: Postgresql   [Index]


7.4 Examples for accessing Postgresql

The examples assume that there is a database named test and you have the necessary rights to access it without password (probably the database is on a server at the local machine) as the default user, i.e. the user with the same name as your current operating system account.

Each example contains code for cleaning up, but, for more clarity, the cleanup is not enforced with Octaves unwind_protect or with an SQL transaction. If something goes wrong, you can drop the database test – this should assure purging any created large objects.

You can also type demo pq_connect to access some demo code. But it is possibly more difficult to read. test pq_connect runs some functionality tests. The preconditions (access to a database named test) are the same as for the code in the current section.

database-2.4.4/doc/html/PaxHeaders.8241/SQL-data-types.html0000644000000000000000000000013113444726153020057 xustar0030 mtime=1553181803.183120748 29 atime=1553181803.15911826 30 ctime=1553181803.415144792 database-2.4.4/doc/html/SQL-data-types.html0000644000175000017500000001712713444726153020341 0ustar00olafolaf00000000000000 database_doc: SQL data types

Next: , Previous: , Up: Top   [Index]


3 Representation in Octave of types defined by SQL

For types specific to database implementations, see Postgresql data types.

The last column indicates whether the SQL type is automatically deduced by this packages functions from the representation of the data in Octave. If not, the correct SQL type must be specified by the user if the data is sent from Octave to the database.

The listed names of SQL data types are those which are used by the functions of this package. They are sometimes different from the original SQL typenames, e.g. int2, int4, and int8 instead of smallint, integer, and bigint, respectively. If not obvious, the original SQL typename is given in parantheses.

SQLOctaveauto
boollogical scalaryes
bytea (variable length binary string)array of uint8, one-dimensional if converted from SQL datayes
float8double scalaryes
float4single scalaryes
varcharstringno
bpchar (char)stringno
int2int16 scalaryes
int4int32 scalaryes
int8int64 scalaryes
timestamp8-byte-time-value (see below), positive or negative difference to 2000-01-01 00:00no
timestamptzas timestampno
time8-byte-time-value (see below)no
timetz2-element cell array with 8-byte-time-value (see below, time of day) and int32 scalar (time zone in seconds, negative east of UTC)no
dateint32 scalar, positive or negative difference to 2000-01-01no
interval3-element cell array with 8-byte-time-value (see below), int32 (days), and int32 (months)no
bitstructure with fields bitlen (int32, number of valid bits) and bits (uint8 array, 8 bits per entry, first entry contains the leftmost bits, last entry may contain less than 8 bits)no
varbitas bityes
xmlstringno
any arrayStructure with fields data (holding a cell-array with entries of a type corresponding to the SQL element type), ndims (holding the number of dimensions of the corresponding SQL array, since this can not be deduced from the dimensions of the Octave cell-array in all cases), and optionally (but always present in returned values) lbounds (a row vector of enumeration bases for all dimensions, default is ones (1, ndims); enumeration bases different from 1 are supported e.g. by Postgresql). Array elements may not correspond to arrays in SQL (use additional dimensions for this), but may correspond to composite types, which is allowed to lead to arbitrarily deep nesting.no
any composite type (row type)One-dimensional cell-array with entries of types corresponding to the respective SQL types. Entries may also correspond to an array-type or composite type; this is allowed to lead to arbitrarily deep nesting.no

8-byte-time-value: int64 scalar, representing microseconds, if server is configured for integer date/time; double scalar, representing seconds, if server is configured for float date/time. If the type (integer or float) of an input Octave variable for an 8-byte-time-value does not match the server configuration, there is no automatic conversion but an error is thrown.

Octaves NA corresponds to an SQL NULL value (not NaN, which is interpreted as a value of a float type!).


Next: , Previous: , Up: Top   [Index]

database-2.4.4/doc/PaxHeaders.8241/README-postgresql0000644000000000000000000000013213444726064016600 xustar0030 mtime=1553181748.468190812 30 atime=1553181748.468190812 30 ctime=1553181803.415144792 database-2.4.4/doc/README-postgresql0000644000175000017500000000272513444726064017057 0ustar00olafolaf00000000000000Octave postgresql interface Functions: pq_connect: connect to a postgresql database, pq_exec_params: execute an SQL command with optional parameters and return result, pq_update_types: used if defined types change during connection time, pq_lo_import: import large object from client side, pq_lo_export: export large object to client side, pq_lo_unlink: delete large object, pq_close: disconnect from database, pq_conninfo: get information on connection and server. Features: - number of connections not limited, - mapping of postgresql types to Octave types in data exchange in both directions, - arbitrarily deeply nested composite- and array-types, - caches converter lookups for composite type elements, - binary data transfer, - reads postgresql system catalogs to get type information, - types can be scheme-qualified. State: All commands should work with pq_exec_params, copy from stdin and copy to stdout are implemented from/to files at client side, copy from stdin is also possible from an Octave cell-array. There are no plans to implement copy to stdout into an Octave cell-array (does not safely fit into the framework, and select should be equivalent). The whole framework including conversion of composite and array types with the resulting possible recursion, enum types, and all base types except textsearch types are implemented. Large object import, export, and unlink works, also import/export from/to pipes. Please report bugs. database-2.4.4/doc/PaxHeaders.8241/dev-postgresql0000644000000000000000000000013213444726064016421 xustar0030 mtime=1553181748.527690722 30 atime=1553181803.415144792 30 ctime=1553181803.415144792 database-2.4.4/doc/dev-postgresql/0000755000175000017500000000000013444726064016747 5ustar00olafolaf00000000000000database-2.4.4/doc/dev-postgresql/PaxHeaders.8241/conversions.tex0000644000000000000000000000013213444726064021570 xustar0030 mtime=1553181748.527690722 30 atime=1553181748.527690722 30 ctime=1553181803.415144792 database-2.4.4/doc/dev-postgresql/conversions.tex0000644000175000017500000001200013444726064022032 0ustar00olafolaf00000000000000\documentclass[a4paper,landscape]{article} \usepackage[utf8]{inputenc} \usepackage[landscape]{geometry} \usepackage{longtable} \usepackage[pdftex, %%% hyper-references for pdflatex breaklinks=true]{hyperref}% %%% break links if exceeding a single line \pdfadjustspacing=1 %%% force LaTeX-like character spacing \oddsidemargin=0mm \headsep=0mm \headheight=0mm \topmargin=0mm \textwidth=287mm \textheight=160mm \hoffset=-20mm \begin{document} \begin{longtable}{lp{40mm}p{40mm}p{50mm}p{40mm}p{50mm}} type & oid & array-oid & octave type & need to specify type & conversion \\\hline int4 & 23 & 1007 & int32 & no & NBO \\ int2 & 21 & 1005 & int16 & no & NBO \\ int8 & 20 & 1016 & int64 & no & NBO \\ float4 & 700 & 1021 & single & no & NBO \\ float8 & 701 & 1022 & double & no & NBO \\ numeric & 1700 & 1231 & string & yes & int16: ndigits, int16: weight of first digit, int16: sign (pos: 0, neg: 0x4000, NaN: 0xC000), int16: display scale, ndigits x int8: digits \\ money & 790 & 791 & int64 & yes & NBO \\ text & 25 & 1009 & string & no & to server as is without trailing zero, server does conversion of character encoding, if necessary; from server string with already client-adapted character encoding (?) \\ varchar & 1043 & 1015 & string & yes & same as text \\ bpchar (character(n)) & 1042 & 1014 & string & yes & same as text \\ name & & & string $<$ NAMEDATALEN & yes & same as text \\ bytea & 17 & 1001 & uint8 vector & no & no conversion \\ timestamp & 1114 & 1115 & int64 or double & yes & see file timeformats.txt \\ timestamptz & 1184 & 1185 & int64 or double & yes & see file timeformats.txt \\ time & 1083 & 1183 & int64 or double & yes & see file timeformats.txt \\ timetz & 1266 & 1270 & cell: int64 or double, int32 & yes & see file timeformats.txt \\ date & 1082 & 1182 & int32 & yes & see file timeformats.txt \\ interval & 1186 & 1187 & string & cell: int64 or double, int32, int32 & see file timeformats.txt \\ bool & 16 & 1000 & bool & no & no conversion \\ enum & variable & 705 (``unknown'') (?) & string & yes & (to server and from server as is without trailing zero (?))\\ point & 600 & 1017 & 2-element float vector & no & double by double, NBO \\ line (?) & 628 & 629 & 4-element float vector & yes & double by double, NBO \\ lseg & 601 & 1018 & 4-element float vector & no & double by double, NBO \\ box & 603 & 1020 & 4-element float vector & yes & double by double, NBO \\ path & 602 & 1019 & structure with fields ``closed'' (boolean, is path closed?) and ``path'' (2n-element float vector) & yes & NBO, 1 byte (closed ? 1 : 0), int32 (npts), 2n double \\ polygon & 604 & 1027 & 2n-element float vector & yes & NBO, int32 (npts), 2n double \\ circle & 718 & 719 & 3-element float vector & no & double by double, NBO \\ inet & 869 & 1041 & 4 or 5-element uint8 vector or 8 or 9-element uint16 vector & yes & uint8: \nolinkurl{AF_INET}, \nolinkurl{AF_INET} + 1 means \nolinkurl{AF_INET6}; uint8: number of set maskbits (in element 5 or 9 of octave vector, default 32 and 128); uint8: \nolinkurl{is_cidr}?; uint8: addrsize (4 or 16(?)); 4x or 16x uint8: address (left to right) \\ cidr & 650 & 651 & see inet & see inet & see inet \\ macaddr & 829 & 1040 & 6-element uint8 vector & yes & 6x uint8 (left to right) \\ bit & 1560 & 1561 & structure, fields ``bitlen'' (int32) and ``bits'' (uint8 array) & yes & int32 (NBO): nbits; nbytes times uint8 (left to right, first byte full) \\ varbit & 1562 & 1563 & see bit & yes & see bit \\ tsvector & 3614 & 3643 & No, do not provide communication of this type with Octave. one-dimensional cell-array of lexemes, which are one-dimensional cell-arrays of length 3, first entry word, second entry vector of positions (possibly empty), third entry vector of weights (same length as positions), set to zeros (weight D) if no weights are given & yes & int32: nlexemes, nlexemes x (zero-terminated lexeme (from server: already in correct encoding), uint16: number of position/weight-data (:= npos), npos x uint16: first 2 bits weight (0 == D?) and last 14 bits position) \\ tsquery & 3615 & 3645 & Do not provide communication of this type with Octave. & & \\ uuid & 2950 & 2951 & 16-element uint8 vector & yes & 16 x uint8, left to right \\ xml & 142 & 143 & string & yes & \\ array & see other types & (another dimension) & (see \nolinkurl{pq_exec_params} help text) & yes & int32: ndim, int32: \nolinkurl{has_null}\nolinkurl{(_bitmap)} ? 1 : 0, uint32: element-oid, 2 x ndim x int32: ((dims[], lbounds[]), ()), nelem x (int32: -1 for NULL element or (uint32: length without header, data without header in the datatypes binary format)) \\ record & variable & & one-dimensional cell-array with entries of respective types & yes & int32: ncols, ncols x (uint32: element-oid, int32: -1 for NULL element or (uint32: length without header, data without header in the datatypes binary format)) \\ oid & (obsolete information 24, 26, 2202--2206, 3734, 3769) & (obsolete information 1008, 1009, 2207--2211, 3735, 3770) & uint32 & no & uint32 \\ \end{longtable} \end{document} database-2.4.4/doc/dev-postgresql/PaxHeaders.8241/timeformats.txt0000644000000000000000000000013213444726064021571 xustar0030 mtime=1553181748.527690722 30 atime=1553181748.527690722 30 ctime=1553181803.415144792 database-2.4.4/doc/dev-postgresql/timeformats.txt0000644000175000017500000000111013444726064022033 0ustar00olafolaf00000000000000timestamp: Timestamp (8 byte, float or int) (microseconds (int) or seconds (float) before or after 2000-01-01 00:00) timestamptz: TimestampTz (8 byte, float or int) (as timestamp) interval: TimeOffset (8 byte, float or int) (microseconds (int) or seconds (float)) int32 (days) int32 (months) time: TimeADT (8 byte, float or int) (microseconds (int) or seconds (float) ?) timetz: TimeADT (8 byte, float or int) (microseconds (int) or seconds (float) ?) int32 (timezone in seconds) date: int32 (difference to 2000-01-01) database-2.4.4/doc/PaxHeaders.8241/database.txi0000644000000000000000000000013213444726064016011 xustar0030 mtime=1553181748.499924097 30 atime=1553181802.086987512 30 ctime=1553181803.415144792 database-2.4.4/doc/database.txi0000644000175000017500000006055113444726064016271 0ustar00olafolaf00000000000000\input texinfo @c %**start of header @setfilename database.info @settitle database_doc @c %**end of header @c Nowadays the predined function index has entries for each @deftypefn @c in additiont to each @findex. @defcodeindex mfn @copying General documentation for the database package for Octave. Copyright @copyright{} 2016--2018 @email{Olaf Till } You can redistribute this documentation and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this documentation; if not, see . @end copying @include macros.texi @macro mysee @ifhtml see @end ifhtml @end macro @titlepage @title General documentation for the documentation package for Octave @page @vskip 0pt plus 1filll @insertcopying @end titlepage @c No table of contents. The table would occupy most of the top node in @c html and IMHO misleads the user to use the table instead of the menu @c structure of the nodes, which would let some information unused. @c @c @contents @c ------------------------------------------------------------------ @node Top @top General documentation for the database package for Octave @ifhtml The info version of this document is accessible, after package installation, from the Octave commandline with @code{database_doc()}. @end ifhtml This documentation applies to version @PACKAGEVERSION of the database package. The database package enables accessing SQL databases from Octave. Differences between database implementations will inevitably cause some of this packages functions to be specific for a certain implementation. Currently, however, this package only supports the Postgresql database. Later additions might support further databases, and possibly some general functions (with only very basic functionality), which can be used for all backends, will also be provided. This documentation currently describes the concepts of SQL access in 'database' and the details for Postgresql. Familiarity with SQL and the database implementation (Postgresql) is assumed. @menu * Installation:: Installation hints. * Concept:: Introduction and package concept. * SQL data types:: Representation in Octave of types defined by SQL. * Arbitrary Octave types:: Storing arbitrary Octave types in a database. * Setting options:: Functions for setting or retrieving options. * Documentation:: Function database_doc to view documentation. Specific databases * Postgresql:: Description of access to Postgresql databases. Indices * Function index:: Index of functions in database. * Concept index:: Concept index. @end menu @c ------------------------------------------------------------------ @node Installation @chapter Installation hints Maybe your distribution provides the database package. If not, or if you want a newer version, Octaves @code{pkg} command allows building the package from source and installing it. Note that you have to @code{load} any Octave package before you can use it. See Octaves documentation of @code{pkg}. In building from source with @code{pkg}, some preconditions of the system are checked, in particular the presence of the @code{pq} library of Postgresql. If you have to install a package of your operating system with @code{libpq}, you usually also need to install the so called development package (named @code{libpq-dev} or similar). @c ------------------------------------------------------------------ @node Concept @chapter Introduction and package concept To enable scripting of SQL access, particularly combinations of SQL commands with temporary local storage or local processing of data, for almost each SQL data type a corresponding representation of the data in Octave is defined. This includes the SQL array types and user-defined SQL composite types (row types) of arbitrary nesting depth. Octave variables containing these corresponding representations are created by the package if data is received from a database by a @code{select} query, and correspondingly are used for sending data to the database. This data exchange is lossless if the database backend allows it (which is the case for Postgresql). The representations of SQL types in Octave are the 'naturally' corresponding Octave types, if possible. They can also be created directly in Octave and sent to a database. The package keeps a notion of all SQL types available in a database. This information is automatically retrieved after connecting. If the user creates new types with SQL commands, a package function for refreshing the packages information on types must be called for the type to be available within the same session. The same function should be called if the session continues after deletion of types. The package provides functions for issuing SQL commands whose text is provided by the user. The command text can contain placeholders for data. The data, corresponding to these placeholders, can be passed to the function in separate arguments. In queries, not only data is returned, but also information on data type and column names. @c ------------------------------------------------------------------ @node SQL data types @chapter Representation in Octave of types defined by SQL @cindex data types For types specific to database implementations, @mysee @ref{Postgresql data types}. The last column indicates whether the SQL type is automatically deduced by this packages functions from the representation of the data in Octave. If not, the correct SQL type must be specified by the user if the data is sent from Octave to the database. The listed names of SQL data types are those which are used by the functions of this package. They are sometimes different from the original SQL typenames, e.g. @code{int2}, @code{int4}, and @code{int8} instead of @code{smallint}, @code{integer}, and @code{bigint}, respectively. If not obvious, the original SQL typename is given in parantheses. @multitable {aaaaaaaaaaaaa} {Octave type blah blah blah blah blah} {auto} @headitem SQL @tab Octave @tab auto @item bool @tab logical scalar @tab yes @item bytea (variable length binary string) @tab array of uint8, one-dimensional if converted from SQL data @tab yes @item float8 @tab double scalar @tab yes @item float4 @tab single scalar @tab yes @item varchar @tab string @tab no @item bpchar (char) @tab string @tab no @item int2 @tab int16 scalar @tab yes @item int4 @tab int32 scalar @tab yes @item int8 @tab int64 scalar @tab yes @item timestamp @tab 8-byte-time-value (see below), positive or negative difference to 2000-01-01 00:00 @tab no @item timestamptz @tab as timestamp @tab no @item time @tab 8-byte-time-value (see below) @tab no @item timetz @tab 2-element cell array with 8-byte-time-value (see below, time of day) and int32 scalar (time zone in seconds, negative east of UTC) @tab no @item date @tab int32 scalar, positive or negative difference to 2000-01-01 @tab no @item interval @tab 3-element cell array with 8-byte-time-value (see below), int32 (days), and int32 (months) @tab no @item bit @tab structure with fields @code{bitlen} (int32, number of valid bits) and @code{bits} (uint8 array, 8 bits per entry, first entry contains the leftmost bits, last entry may contain less than 8 bits) @tab no @item varbit @tab as bit @tab yes @item xml @tab string @tab no @item any array @tab Structure with fields @code{data} (holding a cell-array with entries of a type corresponding to the SQL element type), @code{ndims} (holding the number of dimensions of the corresponding SQL array, since this can not be deduced from the dimensions of the Octave cell-array in all cases), and optionally (but always present in returned values) @code{lbounds} (a row vector of enumeration bases for all dimensions, default is @code{ones (1, ndims)}; enumeration bases different from @code{1} are supported e.g. by Postgresql). Array elements may not correspond to arrays in SQL (use additional dimensions for this), but may correspond to composite types, which is allowed to lead to arbitrarily deep nesting. @tab no @item any composite type (row type) @tab One-dimensional cell-array with entries of types corresponding to the respective SQL types. Entries may also correspond to an array-type or composite type; this is allowed to lead to arbitrarily deep nesting. @tab no @end multitable 8-byte-time-value: int64 scalar, representing microseconds, if server is configured for integer date/time; double scalar, representing seconds, if server is configured for float date/time. If the type (integer or float) of an input Octave variable for an 8-byte-time-value does not match the server configuration, there is no automatic conversion but an error is thrown. Octaves @code{NA} corresponds to an SQL NULL value (not @code{NaN}, which is interpreted as a value of a float type!). @c ------------------------------------------------------------------ @node Arbitrary Octave types @chapter Storing arbitrary Octave types in a database @cindex arbitrary Octave types If Octave variable types have corresponding SQL types ( @mysee @ref{SQL data types} , also consider the links there to types specific for database implementations), the variables can directly be stored in a database. If not, the variables can be converted to representations of the SQL type bytea and then stored. This way of storing is possible for all Octave types which can be correctly saved and loaded with Octaves @code{save} and @code{load} functions. @menu * var2bytea:: Converting Octave variables to bytea. * bytea2var:: Converting bytea back to Octave variables. @end menu @c ------------------------------------------------------------------ @node var2bytea @section Converting Octave variables to bytea @mfnindex var2bytea @c include function helptext here @DOCSTRING(var2bytea) @c ------------------------------------------------------------------ @node bytea2var @section Converting bytea back to Octave variables @mfnindex bytea2var @c include function helptext here @DOCSTRING(bytea2var) @c ------------------------------------------------------------------ @node Setting options @chapter Functions for setting or retrieving options @cindex options Some functions in 'database' accept options. These are set or retrieved with the following functions. @menu * setdbopts:: Setting options. * getdbopts:: Retrieving options. @end menu @c ------------------------------------------------------------------ @node setdbopts @section Function setdbopts for setting options in 'database' @mfnindex setdbopts @c include function help here @DOCSTRING(setdbopts) @c ------------------------------------------------------------------ @node getdbopts @section Function getdbopts for retrieving options in 'database' @mfnindex getdbopts This function is internally called by the functions of 'database'. @c include function help here @DOCSTRING(getdbopts) @c ------------------------------------------------------------------ @node Documentation @chapter Function database_doc to view documentation @cindex documentation @mfnindex database_doc @c include function helptext here @DOCSTRING(database_doc) @c ------------------------------------------------------------------ @node Postgresql @chapter Description of access to Postgresql databases @cindex postgresql @menu * Postgresql data types:: Representation in Octave of types specific to Postgresql. * Connection functions:: Functions related to the connection to a Postgresql database. * Data exchange:: Functions for data exchange with a Postgresql database. * Examples:: Examples for accessing Postgresql. @end menu @c ------------------------------------------------------------------ @node Postgresql data types @section Representation in Octave of types specific to Postgresql @cindex data types For the general types, defined by SQL and potentially available in each database implementation, @mysee @ref{SQL data types}. The last column indicates whether the SQL type is automatically deduced by this packages functions from the representation of the data in Octave. If not, the correct SQL type must be specified by the user if the data is sent from Octave to the database. @multitable {aaaaaaaaaaaaaaa} {Octave type blah blah blah blah blah} {auto} @headitem Postgresql @tab Octave @tab auto @item oid @tab uint32 scalar @tab yes @item text @tab string @tab yes @item name @tab string of length < @code{NAMEDATALEN} (often 64) @tab no @item money @tab int64 scalar, which is 100 times the currency value to enable storing the 'small currency' (e.g. Cent) fraction in the last two digits @tab no @item point @tab geometric point data for one point (see below) @tab yes @item lseg @tab geometric point data for two points (see below) @tab yes @item line (not yet implemented by postgresql-9.2.4) @tab as lseg @tab no @item box @tab as lseg @tab no @item circle @tab real vector (but the restrictions for type uint8 as in geometric element type apply, as explained below) with 3 elements, no. 1 and 2 centre coordinates, no. 3 radius @tab yes @item polygon @tab geometric point data (see below) @tab no @item path @tab structure with fields @code{closed} (boolean, is path closed?) and @code{path} (geometric point data, see below). @tab no @item inet @tab uint8 array of 4 or 5 elements for IPv4 or uint16 array of 8 or 9 elements for IPv6. 5th or 9th element, respectively, contain number of set bits in network mask, the default (if there are only 4 or 8 elements, respectively) is all bits set. @tab no @item cidr @tab as inet @tab no @item macaddr @tab uint8 array of 6 elements @tab no @item uuid @tab uint8 array of 16 elements @tab no @item any enum type @tab string @tab no @end multitable The 8-byte-time value (see time types in @ref{SQL data types}) can be an int64 scalar, representing microseconds, if the Postgresql server is configured for integer date/time, or a double scalar, representing seconds, if the server is configured for float date/time (deprecated). One can use @ref{pq_conninfo} to query the respective server configuration. Geometric point data: if converting from Octave data, any real array (but if of type uint8, the geometric type name must always be specified, for otherwise uint8 would be considered as bytea) with even number of elements. Two adjacent elements (adjacent if indexed with a single index) define a pair of 2D point coordinates. In converting from Postgresql data, dimensions of Octave geometric point data will be chosen to be (2, n_points) and elements will be of format double. @c ------------------------------------------------------------------ @node Connection functions @section Functions related to the connection to a Postgresql database @cindex database connection @menu * pq_connect:: Connecting to a Postgresql database. * pq_close:: Disconnecting from a Postgresql database. * pq_conninfo:: Retrieving information on the connection and on the server. @end menu @c ------------------------------------------------------------------ @node pq_connect @subsection Connecting to a Postgresql database @mfnindex pq_connect @c include function help here @DOCSTRING(pq_connect) @c ------------------------------------------------------------------ @node pq_close @subsection Disconnecting from a Postgresql database @mfnindex pq_close @c include function help here @DOCSTRING(pq_close) @c ------------------------------------------------------------------ @node pq_conninfo @subsection Retrieving information on the connection and on the server @mfnindex pq_conninfo @c include function help here @DOCSTRING(pq_conninfo) @c ------------------------------------------------------------------ @node Data exchange @section Functions for data exchange with a Postgresql database @cindex data exchange, Postgresql @menu * pq_exec_params:: Issuing SQL commands. * pq_update_types:: Updating type information. Large objects * pq_lo_import:: Importing large objects into a database. * pq_lo_export:: Exporting large objects from a database. * pq_lo_unlink:: Deleting large objects from a database. * pq_lo_view:: Viewing large objects. @end menu @c ------------------------------------------------------------------ @node pq_exec_params @subsection Issuing SQL commands @mfnindex pq_exec_params @c include function helptext here @DOCSTRING(pq_exec_params) @subheading Type mapping For the mapping of currently implemented Postgresql types to Octave types, @mysee @ref{Postgresql data types}. @c ------------------------------------------------------------------ @node pq_update_types @subsection Updating type information @mfnindex pq_update_types @c include function helptext here @DOCSTRING(pq_update_types) @c ------------------------------------------------------------------ @node pq_lo_import @subsection Importing large objects into a database @mfnindex pq_lo_import @c include function helptext here @DOCSTRING(pq_lo_import) @c ------------------------------------------------------------------ @node pq_lo_export @subsection Exporting large objects from a database @mfnindex pq_lo_export @c include function helptext here @DOCSTRING(pq_lo_export) @c ------------------------------------------------------------------ @node pq_lo_unlink @subsection Deleting large objects from a database @mfnindex pq_lo_unlink @c include function helptext here @DOCSTRING(pq_lo_unlink) @c ------------------------------------------------------------------ @node pq_lo_view @subsection Viewing large objects @mfnindex pq_lo_view @c include function helptext here @DOCSTRING(pq_lo_view) @c ------------------------------------------------------------------ @node Examples @section Examples for accessing Postgresql @cindex postgresql examples @cindex examples, postgresql The examples assume that there is a database named @code{test} and you have the necessary rights to access it without password (probably the database is on a server at the local machine) as the default user, i.e. the user with the same name as your current operating system account. Each example contains code for cleaning up, but, for more clarity, the cleanup is not enforced with Octaves @code{unwind_protect} or with an SQL transaction. If something goes wrong, you can drop the database @code{test} -- this should assure purging any created large objects. You can also type @code{demo pq_connect} to access some demo code. But it is possibly more difficult to read. @code{test pq_connect} runs some functionality tests. The preconditions (access to a database named @code{test}) are the same as for the code in the current section. @menu * Large objects:: Large objects. * Copy in:: Copy in from Octave variable. * Composite types:: Working with composite types. @end menu @c ------------------------------------------------------------------ @node Large objects @subsection Large objects @example # connect conn = pq_connect (setdbopts ("dbname", "test")); # create table to store large object oids pq_exec_params (conn, "create table programs (name text, image oid);") # start transaction, so we don't miss storing the oid pq_exec_params (conn, "begin;") # download image, pipe it to a large objects and note its oid # (you need `wget' to be installed) oid = pq_lo_import (conn, "wget -q -O - https://www.gnu.org/software/octave/img/example-mesh.svg |") # write oid and program name into the table pq_exec_params (conn, "insert into programs values ($1, $2);", @{"Octave", oid@}) # finish transaction pq_exec_params (conn, "commit;") # find and retrieve the oid searching for the program name foid = pq_exec_params (conn, "select image from programs where name = $1;", @{"Octave"@}).data@{1@} # view large object corresponding to found @code{foid} # (you need `eog' to be installed, or change to another program able to # display `.svg') pq_lo_view (conn, foid, "eog") # cleanup (we don't use `begin;' and `rollback;' since the # example should show an inner transaction instead) pq_lo_unlink (conn, oid); pq_exec_params (conn, "drop table programs;"); pq_close (conn); @end example @c ------------------------------------------------------------------ @node Copy in @subsection Copy in from Octave variable @example # connect conn = pq_connect (setdbopts ("dbname", "test")); # create table pq_exec_params (conn, "create table testdata (a float8, b float8, label text);") # generate data in Octave data = horzcat (num2cell (reshape (linspace (3, 4, 10), [], 2)), @{"a"; "b"; "c"; "d"; "e"@}) # copy in to the table pq_exec_params (conn, "copy testdata from stdin with (format binary);", setdbopts ("copy_in_from_variable", true, "copy_in_data", data)) # retrieve the data from the table rdata = pq_exec_params (conn, "select * from testdata;").data # cleanup pq_exec_params (conn, "drop table testdata;"); pq_close (conn); @end example @c ------------------------------------------------------------------ @node Composite types @subsection Working with composite types This is a more complicated example with nested composite types. @example # connect conn = pq_connect (setdbopts ("dbname", "test")); # create a first composite type, consisting of a boolean and an array of # booleans pq_exec_params (conn, "create type complex_bool_array_type as (b bool, ba bool[]);") # create a second composite type, consisting of a boolean and the first # composite type pq_exec_params (conn, "create type complex_complex_bool_array_type as (b bool, c complex_bool_array_type);") # create a table with one column, holding the second defined composite # type pq_exec_params (conn, "create table complex_complex_bool_array (a complex_complex_bool_array_type);") # to enable data exchange using the new types, update type infomation pq_update_types (conn); # construct a data element for an SQL array of booleans in Octave d_arr = cell2struct (@{2; @{true, false; true, true@}@}, @{"ndims", "data"@}) # construct a data element for the first defined composite type in # Octave d_c1 = @{true; d_arr@}; # construct a data element for the second defined composite type in # Octave d_c2 = @{false; d_c1@}; # insert the data element of the second composite type into the table; # note that in this case specification of the parameter type in # `param_types' is necessary pq_exec_params (conn, "insert into complex_complex_bool_array values ($1);", @{d_c2@}, setdbopts ("param_types", @{"complex_complex_bool_array_type"@})) # read contents of the table result = pq_exec_params (conn, "select * from complex_complex_bool_array"); # only for demonstration purpouses, verify that the read data matches # the element constructed in Octave; # for this, the field `lbounds' is deleted from the returned data # # note that the verification would not work if we had constructed the # data element with rows of cell-arrays instead of columns, which would # also have been possible rdata = result.data@{1@}; rdata@{2@}@{2@} = rmfield (rdata@{2@}@{2@}, "lbounds"); isequal (d_c2, rdata) # view returned column names result.columns # view returned type information result.types # cleanup pq_exec_params (conn, "drop table complex_complex_bool_array;") pq_exec_params (conn, "drop type complex_complex_bool_array_type;") pq_exec_params (conn, "drop type complex_bool_array_type;") pq_close (conn); @end example @c ------------------------------------------------------------------ @node Function index @unnumbered Index of functions in database @printindex mfn @c ------------------------------------------------------------------ @node Concept index @unnumbered Concept index @printindex cp @bye database-2.4.4/doc/PaxHeaders.8241/macros.texi0000644000000000000000000000013213444726064015676 xustar0030 mtime=1553181748.531657383 30 atime=1553181802.347020038 30 ctime=1553181803.415144792 database-2.4.4/doc/macros.texi0000644000175000017500000000472113444726064016153 0ustar00olafolaf00000000000000@c Copyright (C) 2012-2013 John W. Eaton @c @c This file is part of Octave. @c @c Octave is free software; you can redistribute it and/or modify it @c under the terms of the GNU General Public License as published by the @c Free Software Foundation; either version 3 of the License, or (at @c your option) any later version. @c @c Octave is distributed in the hope that it will be useful, but WITHOUT @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License @c for more details. @c @c You should have received a copy of the GNU General Public License @c along with Octave; see the file COPYING. If not, see @c . @c The following macro marks words that aspell should ignore during @c spellchecking. Within Texinfo it has no effect as it merely replaces @c the macro call with the argument itself. @macro nospell {arg} \arg\ @end macro @c The following macro works around the Info/plain text expansion of @code{XXX} @c which is `XXX'. This looks particularly bad when the macro body is @c single or double-quoted text, such as a property value `"position"' @ifinfo @rmacro qcode{arg} \arg\ @end rmacro @end ifinfo @ifnotinfo @rmacro qcode{arg} @code{\arg\} @end rmacro @end ifnotinfo @c The following macro is used for the on-line help system, but we don't @c want lots of `See also: foo, bar, and baz' strings cluttering the @c printed manual (that information should be in the supporting text for @c each group of functions and variables). @c @c Implementation Note: @c For TeX, @vskip produces a nice separation. @c For Texinfo, '@sp 1' should work, but in practice produces ugly results @c for HTML. We use a simple blank line to produce the correct behavior. @macro seealso {args} @iftex @vskip 2pt @end iftex @ifnottex @end ifnottex @ifnotinfo @noindent @strong{See also:} \args\. @end ifnotinfo @ifinfo @noindent See also: \args\. @end ifinfo @end macro @c The following macro works around a situation where the Info/plain text @c expansion of the @code{XXX} macro is `XXX'. The use of the apostrophe @c can be confusing if the code segment itself ends with a transpose operator. @ifinfo @macro tcode{arg} \arg\ @end macro @end ifinfo @ifnotinfo @macro tcode{arg} @code{\arg\} @end macro @end ifnotinfo @c FIXME: someday, when Texinfo 5.X is standard, we might replace this with @c @backslashchar, which is a new addition to Texinfo. @macro xbackslashchar \\ @end macro database-2.4.4/doc/PaxHeaders.8241/README0000644000000000000000000000013213444726064014377 xustar0030 mtime=1553181748.468190812 30 atime=1553181748.468190812 30 ctime=1553181803.415144792 database-2.4.4/doc/README0000644000175000017500000000050013444726064014643 0ustar00olafolaf00000000000000Interfaces for SQL databases should go into this package. Currently only a postgresql interface is implemented (see README-postgresql). Interfaces to other database systems need to be contributed by others. As soon as interfaces to further database systems emerge we should move the code into respective subdirectories. database-2.4.4/doc/PaxHeaders.8241/database.texi0000644000000000000000000000013213444726152016154 xustar0030 mtime=1553181802.086987512 30 atime=1553181802.343019537 30 ctime=1553181803.415144792 database-2.4.4/doc/database.texi0000644000175000017500000011012613444726152016426 0ustar00olafolaf00000000000000@c This file is generated automatically by the packages munge-texi.pl. \input texinfo @c %**start of header @setfilename database.info @settitle database_doc @c %**end of header @c Nowadays the predined function index has entries for each @deftypefn @c in additiont to each @findex. @defcodeindex mfn @copying General documentation for the database package for Octave. Copyright @copyright{} 2016--2018 @email{Olaf Till } You can redistribute this documentation and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this documentation; if not, see . @end copying @include macros.texi @macro mysee @ifhtml see @end ifhtml @end macro @titlepage @title General documentation for the documentation package for Octave @page @vskip 0pt plus 1filll @insertcopying @end titlepage @c No table of contents. The table would occupy most of the top node in @c html and IMHO misleads the user to use the table instead of the menu @c structure of the nodes, which would let some information unused. @c @c @contents @c ------------------------------------------------------------------ @node Top @top General documentation for the database package for Octave @ifhtml The info version of this document is accessible, after package installation, from the Octave commandline with @code{database_doc()}. @end ifhtml This documentation applies to version 2.4.4 of the database package. The database package enables accessing SQL databases from Octave. Differences between database implementations will inevitably cause some of this packages functions to be specific for a certain implementation. Currently, however, this package only supports the Postgresql database. Later additions might support further databases, and possibly some general functions (with only very basic functionality), which can be used for all backends, will also be provided. This documentation currently describes the concepts of SQL access in 'database' and the details for Postgresql. Familiarity with SQL and the database implementation (Postgresql) is assumed. @menu * Installation:: Installation hints. * Concept:: Introduction and package concept. * SQL data types:: Representation in Octave of types defined by SQL. * Arbitrary Octave types:: Storing arbitrary Octave types in a database. * Setting options:: Functions for setting or retrieving options. * Documentation:: Function database_doc to view documentation. Specific databases * Postgresql:: Description of access to Postgresql databases. Indices * Function index:: Index of functions in database. * Concept index:: Concept index. @end menu @c ------------------------------------------------------------------ @node Installation @chapter Installation hints Maybe your distribution provides the database package. If not, or if you want a newer version, Octaves @code{pkg} command allows building the package from source and installing it. Note that you have to @code{load} any Octave package before you can use it. See Octaves documentation of @code{pkg}. In building from source with @code{pkg}, some preconditions of the system are checked, in particular the presence of the @code{pq} library of Postgresql. If you have to install a package of your operating system with @code{libpq}, you usually also need to install the so called development package (named @code{libpq-dev} or similar). @c ------------------------------------------------------------------ @node Concept @chapter Introduction and package concept To enable scripting of SQL access, particularly combinations of SQL commands with temporary local storage or local processing of data, for almost each SQL data type a corresponding representation of the data in Octave is defined. This includes the SQL array types and user-defined SQL composite types (row types) of arbitrary nesting depth. Octave variables containing these corresponding representations are created by the package if data is received from a database by a @code{select} query, and correspondingly are used for sending data to the database. This data exchange is lossless if the database backend allows it (which is the case for Postgresql). The representations of SQL types in Octave are the 'naturally' corresponding Octave types, if possible. They can also be created directly in Octave and sent to a database. The package keeps a notion of all SQL types available in a database. This information is automatically retrieved after connecting. If the user creates new types with SQL commands, a package function for refreshing the packages information on types must be called for the type to be available within the same session. The same function should be called if the session continues after deletion of types. The package provides functions for issuing SQL commands whose text is provided by the user. The command text can contain placeholders for data. The data, corresponding to these placeholders, can be passed to the function in separate arguments. In queries, not only data is returned, but also information on data type and column names. @c ------------------------------------------------------------------ @node SQL data types @chapter Representation in Octave of types defined by SQL @cindex data types For types specific to database implementations, @mysee @ref{Postgresql data types}. The last column indicates whether the SQL type is automatically deduced by this packages functions from the representation of the data in Octave. If not, the correct SQL type must be specified by the user if the data is sent from Octave to the database. The listed names of SQL data types are those which are used by the functions of this package. They are sometimes different from the original SQL typenames, e.g. @code{int2}, @code{int4}, and @code{int8} instead of @code{smallint}, @code{integer}, and @code{bigint}, respectively. If not obvious, the original SQL typename is given in parantheses. @multitable {aaaaaaaaaaaaa} {Octave type blah blah blah blah blah} {auto} @headitem SQL @tab Octave @tab auto @item bool @tab logical scalar @tab yes @item bytea (variable length binary string) @tab array of uint8, one-dimensional if converted from SQL data @tab yes @item float8 @tab double scalar @tab yes @item float4 @tab single scalar @tab yes @item varchar @tab string @tab no @item bpchar (char) @tab string @tab no @item int2 @tab int16 scalar @tab yes @item int4 @tab int32 scalar @tab yes @item int8 @tab int64 scalar @tab yes @item timestamp @tab 8-byte-time-value (see below), positive or negative difference to 2000-01-01 00:00 @tab no @item timestamptz @tab as timestamp @tab no @item time @tab 8-byte-time-value (see below) @tab no @item timetz @tab 2-element cell array with 8-byte-time-value (see below, time of day) and int32 scalar (time zone in seconds, negative east of UTC) @tab no @item date @tab int32 scalar, positive or negative difference to 2000-01-01 @tab no @item interval @tab 3-element cell array with 8-byte-time-value (see below), int32 (days), and int32 (months) @tab no @item bit @tab structure with fields @code{bitlen} (int32, number of valid bits) and @code{bits} (uint8 array, 8 bits per entry, first entry contains the leftmost bits, last entry may contain less than 8 bits) @tab no @item varbit @tab as bit @tab yes @item xml @tab string @tab no @item any array @tab Structure with fields @code{data} (holding a cell-array with entries of a type corresponding to the SQL element type), @code{ndims} (holding the number of dimensions of the corresponding SQL array, since this can not be deduced from the dimensions of the Octave cell-array in all cases), and optionally (but always present in returned values) @code{lbounds} (a row vector of enumeration bases for all dimensions, default is @code{ones (1, ndims)}; enumeration bases different from @code{1} are supported e.g. by Postgresql). Array elements may not correspond to arrays in SQL (use additional dimensions for this), but may correspond to composite types, which is allowed to lead to arbitrarily deep nesting. @tab no @item any composite type (row type) @tab One-dimensional cell-array with entries of types corresponding to the respective SQL types. Entries may also correspond to an array-type or composite type; this is allowed to lead to arbitrarily deep nesting. @tab no @end multitable 8-byte-time-value: int64 scalar, representing microseconds, if server is configured for integer date/time; double scalar, representing seconds, if server is configured for float date/time. If the type (integer or float) of an input Octave variable for an 8-byte-time-value does not match the server configuration, there is no automatic conversion but an error is thrown. Octaves @code{NA} corresponds to an SQL NULL value (not @code{NaN}, which is interpreted as a value of a float type!). @c ------------------------------------------------------------------ @node Arbitrary Octave types @chapter Storing arbitrary Octave types in a database @cindex arbitrary Octave types If Octave variable types have corresponding SQL types ( @mysee @ref{SQL data types} , also consider the links there to types specific for database implementations), the variables can directly be stored in a database. If not, the variables can be converted to representations of the SQL type bytea and then stored. This way of storing is possible for all Octave types which can be correctly saved and loaded with Octaves @code{save} and @code{load} functions. @menu * var2bytea:: Converting Octave variables to bytea. * bytea2var:: Converting bytea back to Octave variables. @end menu @c ------------------------------------------------------------------ @node var2bytea @section Converting Octave variables to bytea @mfnindex var2bytea @c include function helptext here @c var2bytea var2bytea.cc @anchor{XREFvar2bytea} @deftypefn {Loadable Function} {} var2bytea (@var{value}, @dots{}) Save input values in uint8 arrays in Octaves binary save format. This function returns as many output variables as input variables are given. The function can be used to prepare storage of Octave variable values as binary strings in a database, if the variables types have no corresponding SQL type. Each variable type which can be correctly saved and loaded with Octaves @code{save} and @code{load} functions is acceptable. The variable value can be restored with the function @code{bytea2var}. Note that the inputs are not variable names, but values. No variable names are saved. Loading the uint8 array with @code{load} (possibly after dumping it to a file) will not work. Example: to convert the first and third column of a cell-array @code{c}, @code{[c@{:, [1, 3]@}] = var2bytea (c@{:, [1, 3]@});} can be used. @seealso{@ref{XREFbytea2var,,bytea2var}} @end deftypefn @c ------------------------------------------------------------------ @node bytea2var @section Converting bytea back to Octave variables @mfnindex bytea2var @c include function helptext here @c bytea2var bytea2var.cc @anchor{XREFbytea2var} @deftypefn {Loadable Function} {} bytea2var (@var{value}, @dots{}) Restore variable values from uint8 arrays generated with @code{var2bytea}. Returns as many output variables as input variables are given. @seealso{@ref{XREFvar2bytea,,var2bytea}} @end deftypefn @c ------------------------------------------------------------------ @node Setting options @chapter Functions for setting or retrieving options @cindex options Some functions in 'database' accept options. These are set or retrieved with the following functions. @menu * setdbopts:: Setting options. * getdbopts:: Retrieving options. @end menu @c ------------------------------------------------------------------ @node setdbopts @section Function setdbopts for setting options in 'database' @mfnindex setdbopts @c include function help here @c setdbopts ../inst/setdbopts.m @anchor{XREFsetdbopts} @deftypefn {Function File} {} setdbopts () @deftypefnx {Function File} {} setdbopts (@var{par}, @var{val}, @dots{}) @deftypefnx {Function File} {} setdbopts (@var{old}, @var{par}, @var{val}, @dots{}) @deftypefnx {Function File} {} setdbopts (@var{old}, @var{new}) Create settings structure for database functions. When called without any input or output arguments, 'setdbopts' prints a list of all valid optimization parameters. When called with one output and no inputs, return an options structure with all valid option parameters initialized to '[]'. When called with a list of parameter/value pairs, return an options structure with only the named parameters initialized. When the first input is an existing options structure OLD, the values are updated from either the PAR/VAL list or from the options structure NEW. Please see individual database functions for valid settings. (Most of this documentation and this functions code are copied from Octaves 'optimset' function.) @end deftypefn @c ------------------------------------------------------------------ @node getdbopts @section Function getdbopts for retrieving options in 'database' @mfnindex getdbopts This function is internally called by the functions of 'database'. @c include function help here @c getdbopts ../inst/getdbopts.m @anchor{XREFgetdbopts} @deftypefn {Function File} {} getdbopts (@var{options}, @var{parname}) @deftypefnx {Function File} {} getdbopts (@var{options}, @var{parname}, @var{default}) Return a specific setting from a structure created by @code{setdbopts}. If @var{parname} is not a field of the @var{options} structure, return @var{default} if supplied, otherwise return an empty matrix. (This function uses the code of Octaves 'optimget' function.) @end deftypefn @c ------------------------------------------------------------------ @node Documentation @chapter Function database_doc to view documentation @cindex documentation @mfnindex database_doc @c include function helptext here @c database_doc ../inst/database_doc.m @anchor{XREFdatabase_doc} @deftypefn {Function File} {} database_doc () @deftypefnx {Function File} {} database_doc (@var{keyword}) Show database package documentation. Runs the info viewer Octave is configured with on the documentation in info format of the installed database package. Without argument, the top node of the documentation is displayed. With an argument, the respective index entry is searched for and its node displayed. @end deftypefn @c ------------------------------------------------------------------ @node Postgresql @chapter Description of access to Postgresql databases @cindex postgresql @menu * Postgresql data types:: Representation in Octave of types specific to Postgresql. * Connection functions:: Functions related to the connection to a Postgresql database. * Data exchange:: Functions for data exchange with a Postgresql database. * Examples:: Examples for accessing Postgresql. @end menu @c ------------------------------------------------------------------ @node Postgresql data types @section Representation in Octave of types specific to Postgresql @cindex data types For the general types, defined by SQL and potentially available in each database implementation, @mysee @ref{SQL data types}. The last column indicates whether the SQL type is automatically deduced by this packages functions from the representation of the data in Octave. If not, the correct SQL type must be specified by the user if the data is sent from Octave to the database. @multitable {aaaaaaaaaaaaaaa} {Octave type blah blah blah blah blah} {auto} @headitem Postgresql @tab Octave @tab auto @item oid @tab uint32 scalar @tab yes @item text @tab string @tab yes @item name @tab string of length < @code{NAMEDATALEN} (often 64) @tab no @item money @tab int64 scalar, which is 100 times the currency value to enable storing the 'small currency' (e.g. Cent) fraction in the last two digits @tab no @item point @tab geometric point data for one point (see below) @tab yes @item lseg @tab geometric point data for two points (see below) @tab yes @item line (not yet implemented by postgresql-9.2.4) @tab as lseg @tab no @item box @tab as lseg @tab no @item circle @tab real vector (but the restrictions for type uint8 as in geometric element type apply, as explained below) with 3 elements, no. 1 and 2 centre coordinates, no. 3 radius @tab yes @item polygon @tab geometric point data (see below) @tab no @item path @tab structure with fields @code{closed} (boolean, is path closed?) and @code{path} (geometric point data, see below). @tab no @item inet @tab uint8 array of 4 or 5 elements for IPv4 or uint16 array of 8 or 9 elements for IPv6. 5th or 9th element, respectively, contain number of set bits in network mask, the default (if there are only 4 or 8 elements, respectively) is all bits set. @tab no @item cidr @tab as inet @tab no @item macaddr @tab uint8 array of 6 elements @tab no @item uuid @tab uint8 array of 16 elements @tab no @item any enum type @tab string @tab no @end multitable The 8-byte-time value (see time types in @ref{SQL data types}) can be an int64 scalar, representing microseconds, if the Postgresql server is configured for integer date/time, or a double scalar, representing seconds, if the server is configured for float date/time (deprecated). One can use @ref{pq_conninfo} to query the respective server configuration. Geometric point data: if converting from Octave data, any real array (but if of type uint8, the geometric type name must always be specified, for otherwise uint8 would be considered as bytea) with even number of elements. Two adjacent elements (adjacent if indexed with a single index) define a pair of 2D point coordinates. In converting from Postgresql data, dimensions of Octave geometric point data will be chosen to be (2, n_points) and elements will be of format double. @c ------------------------------------------------------------------ @node Connection functions @section Functions related to the connection to a Postgresql database @cindex database connection @menu * pq_connect:: Connecting to a Postgresql database. * pq_close:: Disconnecting from a Postgresql database. * pq_conninfo:: Retrieving information on the connection and on the server. @end menu @c ------------------------------------------------------------------ @node pq_connect @subsection Connecting to a Postgresql database @mfnindex pq_connect @c include function help here @c pq_connect ../inst/pq_connect.m @anchor{XREFpq_connect} @deftypefn {Function File} {@var{connection} =} pq_connect (@var{settings}) Establishes a connection to a postgresql server according to @var{settings} and returns an @code{octave_pq_connection} object @var{connection} which can be passed to other functions of the package. There can be multiple connections. An @code{octave_pq_connection} object contains information on a connection and will be internally altered by the packages functions even though it is only passed as an argument, i.e. Octaves 'pass by value' semantics are not adhered to in this case. @var{settings} can be set by @code{setdbopts} (copied from Octaves @code{optimset}) and can contain (defaults depend on Postgresql): @code{host} (hostname), @code{hostaddr} (numeric host address), @code{port} (port to connect to), @code{dbname} (database to connect to), @code{user} (user name to connect as), @code{password}, @code{connect_timeout}, @code{options} (command-line options to send to the server at run-time, see Postgresql documentation), @code{sslmode} (@code{disable}, @code{allow}, @code{prefer}, @code{require}, @code{verify-ca}, or @code{verify-full}; see Postgresql documentation of SSL support), @code{sslcert} (file name of client SSL certificate), @code{sslkey} (location of secret key for client certificate, file name or external OpenSSL engine (colon-separated engine name and an engine-specific key identifier)), @code{sslrootcert} (file name of root SSL certificate), @code{sslcrl} (file name of SSL certificate revocation list), @code{krbsrvname} (kerberos service name), @code{service} (service name in pq_service.conf to use for additional parameters). All these settings are passed to the server as they are, so it may be better to consult the postgresql documentation for them, e.g. the documentation of the PQconnectdb function in libpq. @seealso{@ref{XREFpq_exec_params,,pq_exec_params}, @ref{XREFpq_update_types,,pq_update_types}} @end deftypefn @c ------------------------------------------------------------------ @node pq_close @subsection Disconnecting from a Postgresql database @mfnindex pq_close @c include function help here @c pq_close pq_close.cc @anchor{XREFpq_close} @deftypefn {Loadable Function} pq_close (@var{connection}) Closes connection @var{connection} to a postgresql server. @seealso{@ref{XREFpq_connect,,pq_connect}} @end deftypefn @c ------------------------------------------------------------------ @node pq_conninfo @subsection Retrieving information on the connection and on the server @mfnindex pq_conninfo @c include function help here @c pq_conninfo pq_conninfo.cc @anchor{XREFpq_conninfo} @deftypefn {Loadable Function} {@var{val} =} pq_conninfo (@var{connection}, @var{label}) Retrieves connection information for postgresql connection @var{connection}, specified by the string @var{label}, and returns the value of this information in @var{val}. The type of @var{val} depends on the requested information. Currently, the only recognized @var{label} is @code{'integer_datetimes'}; @var{val} is @code{true} if 8-byte date and time values are stored as integer in the server, and @code{false} if they are stored as @code{double} (which is deprecated). @end deftypefn @c ------------------------------------------------------------------ @node Data exchange @section Functions for data exchange with a Postgresql database @cindex data exchange, Postgresql @menu * pq_exec_params:: Issuing SQL commands. * pq_update_types:: Updating type information. Large objects * pq_lo_import:: Importing large objects into a database. * pq_lo_export:: Exporting large objects from a database. * pq_lo_unlink:: Deleting large objects from a database. * pq_lo_view:: Viewing large objects. @end menu @c ------------------------------------------------------------------ @node pq_exec_params @subsection Issuing SQL commands @mfnindex pq_exec_params @c include function helptext here @c pq_exec_params ../inst/pq_exec_params.m @anchor{XREFpq_exec_params} @deftypefn {Function File} pq_exec_params (@var{connection}, @var{command}) @deftypefnx {Loadable Function} pq_exec_params (@var{connection}, @var{command}, @var{params}) @deftypefnx {Loadable Function} pq_exec_params (@var{connection}, @var{command}, @var{settings}) @deftypefnx {Loadable Function} pq_exec_params (@var{connection}, @var{command}, @var{params}, @var{settings}) Sends the string @var{command}, which must contain a single SQL command, over the connection @var{connection}. Parameters in @var{command} can be replaced by $1, $2, etc and their values given in the one-dimensional cell-array @var{params}. Parameters of composite type sent this way must have their type defined in the database. For typeconversions, the package maintains a notion of defined types, which should be refreshed with @code{pq_update_types} if types are defined or dropped after establishing the connection, or if the schema search path changes. @var{settings} is a structure of settings, it can be created by @code{setdbopts}. Settings currently understood by @code{pq_exec_params}: @table @code @item param_types One-dimensional cell-array with type specifications for parameters in @var{params}. If present, must have the same length as @var{params}. Entries may be empty if no specification is necessary (see below). Type specifications are strings corresponding to the entries returned by @code{SELECT typname FROM pg_type WHERE typarray != 0 OR typtype = 'c';}, optionally having @code{[]} appended (without space) to indicate an array. Type specifications can be schema-qualified, otherwise they refer to the visible type with that name. @item copy_in_path, copy_out_path Path to files at the client side for @code{copy from stdin} and @code{copy to stdout}, respectively. @item copy_in_from_variable Logical scalar, default @code{false}. If @code{true}, @code{copy from stdin} uses data from an Octave variable instead of from a file. @item copy_in_data 2-dimensional cell-array with columns of suitable type (see below) -- will be used instead of a file as data for @code{copy from stdin} if @code{copy_in_from_variable} is @code{true}. @item copy_in_types If some columns in @code{copy_in_data} need a type specification (see below), @code{copy_in_types} has to be set to a cell-array with type specifications, with an entry (possibly empty) for each column. @item copy_in_with_oids If you want to copy in with oids when using data from an Octave variable, the first column of the data must contain the OIDs and @code{copy_in_with_oids} has to be set to @code{true} (default @code{false}); @code{with oids} should be specified together with @code{copy from stdin} in the command, otherwise Postgresql will ignore the copied oids. @end table There is no way to @code{copy to stdout} into an Octave variable, but a @code{select} command can be used for this purpose. @code{copy from stdin} from an Octave variable is only supported in binary mode, so this has to be specified in the SQL command. The output depends on the type of command. @itemize @item queries (commands potentially returning data): The output will be a structure with fields @code{data} (containing a cell array with the data, columns correspond to returned database columns, rows correspond to returned tuples), @code{columns} (containing the column headers), and @code{types} (a structure-vector with the postgresql data types of the columns, subfields @code{name} (string with typename), @code{is_array} (boolean), @code{is_composite} (boolean), @code{is_enum} (boolean), and @code{elements} (if @code{is_composite == true}, structure-vector of element types, containing fields corresponding to those of @code{types})). @item copy commands: Nothing is returned (this may change in the future). @item other commands: The output will be the number of affected rows in the database. @end itemize @c The following block will be cut out in the package info file. @seealso{@ref{XREFpq_update_types,,pq_update_types}, @ref{XREFpq_conninfo,,pq_conninfo}} @end deftypefn @subheading Type mapping For the mapping of currently implemented Postgresql types to Octave types, @mysee @ref{Postgresql data types}. @c ------------------------------------------------------------------ @node pq_update_types @subsection Updating type information @mfnindex pq_update_types @c include function helptext here @c pq_update_types pq_update_types.cc @anchor{XREFpq_update_types} @deftypefn {Loadable Function} pq_update_types (@var{connection}) Updates information on existing postgresql types for @var{connection}. Use this before @code{pq_exec_params} if types were created or dropped while the connection was already established or if the schema search path changed. A newly created connection will automatically retrieve this information at connection time. @end deftypefn @c ------------------------------------------------------------------ @node pq_lo_import @subsection Importing large objects into a database @mfnindex pq_lo_import @c include function helptext here @c pq_lo_import pq_lo.cc @anchor{XREFpq_lo_import} @deftypefn {Loadable Function} {@var{oid} =} pq_lo_import (@var{connection}, @var{path}) Imports the file in @var{path} on the client side as a large object into the database associated with @var{connection} and returns the Oid of the new large object. If @var{path} ends with a @code{|}, it is take as a shell command whose output is piped into a large object. @end deftypefn @c ------------------------------------------------------------------ @node pq_lo_export @subsection Exporting large objects from a database @mfnindex pq_lo_export @c include function helptext here @c pq_lo_export pq_lo.cc @anchor{XREFpq_lo_export} @deftypefn {Loadable Function} pq_lo_export (@var{connection}, @var{oid}, @var{path}) Exports the large object of Oid @var{oid} in the database associated with @var{connection} to the file @var{path} on the client side. If @var{path} starts with a @code{|}, it is taken as a shell commant to pipe to. @end deftypefn @c ------------------------------------------------------------------ @node pq_lo_unlink @subsection Deleting large objects from a database @mfnindex pq_lo_unlink @c include function helptext here @c pq_lo_unlink pq_lo.cc @anchor{XREFpq_lo_unlink} @deftypefn {Loadable Function} pq_lo_unlink (@var{connection}, @var{oid}) Removes the large object of Oid @var{oid} from the database associated with @var{connection}. @end deftypefn @c ------------------------------------------------------------------ @node pq_lo_view @subsection Viewing large objects @mfnindex pq_lo_view @c include function helptext here @c pq_lo_view ../inst/pq_lo_view.m @anchor{XREFpq_lo_view} @deftypefn {Function File} pq_lo_view (@var{connection}, @var{oid}, @var{viewer}) Exports the large object of Oid @var{oid} in the database associated with @var{connection} to a temporary file and starts the program @var{viewer} in the background with the name of the temporary file as argument. The temporary file will be removed after termination of the viewer. @end deftypefn @c ------------------------------------------------------------------ @node Examples @section Examples for accessing Postgresql @cindex postgresql examples @cindex examples, postgresql The examples assume that there is a database named @code{test} and you have the necessary rights to access it without password (probably the database is on a server at the local machine) as the default user, i.e. the user with the same name as your current operating system account. Each example contains code for cleaning up, but, for more clarity, the cleanup is not enforced with Octaves @code{unwind_protect} or with an SQL transaction. If something goes wrong, you can drop the database @code{test} -- this should assure purging any created large objects. You can also type @code{demo pq_connect} to access some demo code. But it is possibly more difficult to read. @code{test pq_connect} runs some functionality tests. The preconditions (access to a database named @code{test}) are the same as for the code in the current section. @menu * Large objects:: Large objects. * Copy in:: Copy in from Octave variable. * Composite types:: Working with composite types. @end menu @c ------------------------------------------------------------------ @node Large objects @subsection Large objects @example # connect conn = pq_connect (setdbopts ("dbname", "test")); # create table to store large object oids pq_exec_params (conn, "create table programs (name text, image oid);") # start transaction, so we don't miss storing the oid pq_exec_params (conn, "begin;") # download image, pipe it to a large objects and note its oid # (you need `wget' to be installed) oid = pq_lo_import (conn, "wget -q -O - https://www.gnu.org/software/octave/img/example-mesh.svg |") # write oid and program name into the table pq_exec_params (conn, "insert into programs values ($1, $2);", @{"Octave", oid@}) # finish transaction pq_exec_params (conn, "commit;") # find and retrieve the oid searching for the program name foid = pq_exec_params (conn, "select image from programs where name = $1;", @{"Octave"@}).data@{1@} # view large object corresponding to found @code{foid} # (you need `eog' to be installed, or change to another program able to # display `.svg') pq_lo_view (conn, foid, "eog") # cleanup (we don't use `begin;' and `rollback;' since the # example should show an inner transaction instead) pq_lo_unlink (conn, oid); pq_exec_params (conn, "drop table programs;"); pq_close (conn); @end example @c ------------------------------------------------------------------ @node Copy in @subsection Copy in from Octave variable @example # connect conn = pq_connect (setdbopts ("dbname", "test")); # create table pq_exec_params (conn, "create table testdata (a float8, b float8, label text);") # generate data in Octave data = horzcat (num2cell (reshape (linspace (3, 4, 10), [], 2)), @{"a"; "b"; "c"; "d"; "e"@}) # copy in to the table pq_exec_params (conn, "copy testdata from stdin with (format binary);", setdbopts ("copy_in_from_variable", true, "copy_in_data", data)) # retrieve the data from the table rdata = pq_exec_params (conn, "select * from testdata;").data # cleanup pq_exec_params (conn, "drop table testdata;"); pq_close (conn); @end example @c ------------------------------------------------------------------ @node Composite types @subsection Working with composite types This is a more complicated example with nested composite types. @example # connect conn = pq_connect (setdbopts ("dbname", "test")); # create a first composite type, consisting of a boolean and an array of # booleans pq_exec_params (conn, "create type complex_bool_array_type as (b bool, ba bool[]);") # create a second composite type, consisting of a boolean and the first # composite type pq_exec_params (conn, "create type complex_complex_bool_array_type as (b bool, c complex_bool_array_type);") # create a table with one column, holding the second defined composite # type pq_exec_params (conn, "create table complex_complex_bool_array (a complex_complex_bool_array_type);") # to enable data exchange using the new types, update type infomation pq_update_types (conn); # construct a data element for an SQL array of booleans in Octave d_arr = cell2struct (@{2; @{true, false; true, true@}@}, @{"ndims", "data"@}) # construct a data element for the first defined composite type in # Octave d_c1 = @{true; d_arr@}; # construct a data element for the second defined composite type in # Octave d_c2 = @{false; d_c1@}; # insert the data element of the second composite type into the table; # note that in this case specification of the parameter type in # `param_types' is necessary pq_exec_params (conn, "insert into complex_complex_bool_array values ($1);", @{d_c2@}, setdbopts ("param_types", @{"complex_complex_bool_array_type"@})) # read contents of the table result = pq_exec_params (conn, "select * from complex_complex_bool_array"); # only for demonstration purpouses, verify that the read data matches # the element constructed in Octave; # for this, the field `lbounds' is deleted from the returned data # # note that the verification would not work if we had constructed the # data element with rows of cell-arrays instead of columns, which would # also have been possible rdata = result.data@{1@}; rdata@{2@}@{2@} = rmfield (rdata@{2@}@{2@}, "lbounds"); isequal (d_c2, rdata) # view returned column names result.columns # view returned type information result.types # cleanup pq_exec_params (conn, "drop table complex_complex_bool_array;") pq_exec_params (conn, "drop type complex_complex_bool_array_type;") pq_exec_params (conn, "drop type complex_bool_array_type;") pq_close (conn); @end example @c ------------------------------------------------------------------ @node Function index @unnumbered Index of functions in database @printindex mfn @c ------------------------------------------------------------------ @node Concept index @unnumbered Concept index @printindex cp @bye database-2.4.4/doc/PaxHeaders.8241/database.info0000644000000000000000000000013213444726152016136 xustar0030 mtime=1553181802.559046558 30 atime=1553181802.455033548 30 ctime=1553181803.415144792 database-2.4.4/doc/database.info0000644000175000017500000011536213444726152016417 0ustar00olafolaf00000000000000This is database.info, produced by makeinfo version 6.3 from database.texi. General documentation for the database package for Octave. Copyright (C) 2016-2018 > You can redistribute this documentation and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this documentation; if not, see .  File: database.info, Node: Top, Next: Installation, Up: (dir) General documentation for the database package for Octave ********************************************************* This documentation applies to version 2.4.4 of the database package. The database package enables accessing SQL databases from Octave. Differences between database implementations will inevitably cause some of this packages functions to be specific for a certain implementation. Currently, however, this package only supports the Postgresql database. Later additions might support further databases, and possibly some general functions (with only very basic functionality), which can be used for all backends, will also be provided. This documentation currently describes the concepts of SQL access in 'database' and the details for Postgresql. Familiarity with SQL and the database implementation (Postgresql) is assumed. * Menu: * Installation:: Installation hints. * Concept:: Introduction and package concept. * SQL data types:: Representation in Octave of types defined by SQL. * Arbitrary Octave types:: Storing arbitrary Octave types in a database. * Setting options:: Functions for setting or retrieving options. * Documentation:: Function database_doc to view documentation. Specific databases * Postgresql:: Description of access to Postgresql databases. Indices * Function index:: Index of functions in database. * Concept index:: Concept index.  File: database.info, Node: Installation, Next: Concept, Prev: Top, Up: Top 1 Installation hints ******************** Maybe your distribution provides the database package. If not, or if you want a newer version, Octaves 'pkg' command allows building the package from source and installing it. Note that you have to 'load' any Octave package before you can use it. See Octaves documentation of 'pkg'. In building from source with 'pkg', some preconditions of the system are checked, in particular the presence of the 'pq' library of Postgresql. If you have to install a package of your operating system with 'libpq', you usually also need to install the so called development package (named 'libpq-dev' or similar).  File: database.info, Node: Concept, Next: SQL data types, Prev: Installation, Up: Top 2 Introduction and package concept ********************************** To enable scripting of SQL access, particularly combinations of SQL commands with temporary local storage or local processing of data, for almost each SQL data type a corresponding representation of the data in Octave is defined. This includes the SQL array types and user-defined SQL composite types (row types) of arbitrary nesting depth. Octave variables containing these corresponding representations are created by the package if data is received from a database by a 'select' query, and correspondingly are used for sending data to the database. This data exchange is lossless if the database backend allows it (which is the case for Postgresql). The representations of SQL types in Octave are the 'naturally' corresponding Octave types, if possible. They can also be created directly in Octave and sent to a database. The package keeps a notion of all SQL types available in a database. This information is automatically retrieved after connecting. If the user creates new types with SQL commands, a package function for refreshing the packages information on types must be called for the type to be available within the same session. The same function should be called if the session continues after deletion of types. The package provides functions for issuing SQL commands whose text is provided by the user. The command text can contain placeholders for data. The data, corresponding to these placeholders, can be passed to the function in separate arguments. In queries, not only data is returned, but also information on data type and column names.  File: database.info, Node: SQL data types, Next: Arbitrary Octave types, Prev: Concept, Up: Top 3 Representation in Octave of types defined by SQL ************************************************** For types specific to database implementations, *note Postgresql data types::. The last column indicates whether the SQL type is automatically deduced by this packages functions from the representation of the data in Octave. If not, the correct SQL type must be specified by the user if the data is sent from Octave to the database. The listed names of SQL data types are those which are used by the functions of this package. They are sometimes different from the original SQL typenames, e.g. 'int2', 'int4', and 'int8' instead of 'smallint', 'integer', and 'bigint', respectively. If not obvious, the original SQL typename is given in parantheses. SQL Octave auto -------------------------------------------------------------- bool logical scalar yes bytea array of uint8, one-dimensional if yes (variable converted from SQL data length binary string) float8 double scalar yes float4 single scalar yes varchar string no bpchar (char) string no int2 int16 scalar yes int4 int32 scalar yes int8 int64 scalar yes timestamp 8-byte-time-value (see below), no positive or negative difference to 2000-01-01 00:00 timestamptz as timestamp no time 8-byte-time-value (see below) no timetz 2-element cell array with no 8-byte-time-value (see below, time of day) and int32 scalar (time zone in seconds, negative east of UTC) date int32 scalar, positive or negative no difference to 2000-01-01 interval 3-element cell array with no 8-byte-time-value (see below), int32 (days), and int32 (months) bit structure with fields 'bitlen' no (int32, number of valid bits) and 'bits' (uint8 array, 8 bits per entry, first entry contains the leftmost bits, last entry may contain less than 8 bits) varbit as bit yes xml string no any array Structure with fields 'data' no (holding a cell-array with entries of a type corresponding to the SQL element type), 'ndims' (holding the number of dimensions of the corresponding SQL array, since this can not be deduced from the dimensions of the Octave cell-array in all cases), and optionally (but always present in returned values) 'lbounds' (a row vector of enumeration bases for all dimensions, default is 'ones (1, ndims)'; enumeration bases different from '1' are supported e.g. by Postgresql). Array elements may not correspond to arrays in SQL (use additional dimensions for this), but may correspond to composite types, which is allowed to lead to arbitrarily deep nesting. any composite One-dimensional cell-array with no type (row entries of types corresponding to type) the respective SQL types. Entries may also correspond to an array-type or composite type; this is allowed to lead to arbitrarily deep nesting. 8-byte-time-value: int64 scalar, representing microseconds, if server is configured for integer date/time; double scalar, representing seconds, if server is configured for float date/time. If the type (integer or float) of an input Octave variable for an 8-byte-time-value does not match the server configuration, there is no automatic conversion but an error is thrown. Octaves 'NA' corresponds to an SQL NULL value (not 'NaN', which is interpreted as a value of a float type!).  File: database.info, Node: Arbitrary Octave types, Next: Setting options, Prev: SQL data types, Up: Top 4 Storing arbitrary Octave types in a database ********************************************** If Octave variable types have corresponding SQL types ( *note SQL data types:: , also consider the links there to types specific for database implementations), the variables can directly be stored in a database. If not, the variables can be converted to representations of the SQL type bytea and then stored. This way of storing is possible for all Octave types which can be correctly saved and loaded with Octaves 'save' and 'load' functions. * Menu: * var2bytea:: Converting Octave variables to bytea. * bytea2var:: Converting bytea back to Octave variables.  File: database.info, Node: var2bytea, Next: bytea2var, Up: Arbitrary Octave types 4.1 Converting Octave variables to bytea ======================================== -- Loadable Function: var2bytea (VALUE, ...) Save input values in uint8 arrays in Octaves binary save format. This function returns as many output variables as input variables are given. The function can be used to prepare storage of Octave variable values as binary strings in a database, if the variables types have no corresponding SQL type. Each variable type which can be correctly saved and loaded with Octaves 'save' and 'load' functions is acceptable. The variable value can be restored with the function 'bytea2var'. Note that the inputs are not variable names, but values. No variable names are saved. Loading the uint8 array with 'load' (possibly after dumping it to a file) will not work. Example: to convert the first and third column of a cell-array 'c', '[c{:, [1, 3]}] = var2bytea (c{:, [1, 3]});' can be used. See also: *note bytea2var: XREFbytea2var.  File: database.info, Node: bytea2var, Prev: var2bytea, Up: Arbitrary Octave types 4.2 Converting bytea back to Octave variables ============================================= -- Loadable Function: bytea2var (VALUE, ...) Restore variable values from uint8 arrays generated with 'var2bytea'. Returns as many output variables as input variables are given. See also: *note var2bytea: XREFvar2bytea.  File: database.info, Node: Setting options, Next: Documentation, Prev: Arbitrary Octave types, Up: Top 5 Functions for setting or retrieving options ********************************************* Some functions in 'database' accept options. These are set or retrieved with the following functions. * Menu: * setdbopts:: Setting options. * getdbopts:: Retrieving options.  File: database.info, Node: setdbopts, Next: getdbopts, Up: Setting options 5.1 Function setdbopts for setting options in 'database' ======================================================== -- Function File: setdbopts () -- Function File: setdbopts (PAR, VAL, ...) -- Function File: setdbopts (OLD, PAR, VAL, ...) -- Function File: setdbopts (OLD, NEW) Create settings structure for database functions. When called without any input or output arguments, 'setdbopts' prints a list of all valid optimization parameters. When called with one output and no inputs, return an options structure with all valid option parameters initialized to '[]'. When called with a list of parameter/value pairs, return an options structure with only the named parameters initialized. When the first input is an existing options structure OLD, the values are updated from either the PAR/VAL list or from the options structure NEW. Please see individual database functions for valid settings. (Most of this documentation and this functions code are copied from Octaves 'optimset' function.)  File: database.info, Node: getdbopts, Prev: setdbopts, Up: Setting options 5.2 Function getdbopts for retrieving options in 'database' =========================================================== This function is internally called by the functions of 'database'. -- Function File: getdbopts (OPTIONS, PARNAME) -- Function File: getdbopts (OPTIONS, PARNAME, DEFAULT) Return a specific setting from a structure created by 'setdbopts'. If PARNAME is not a field of the OPTIONS structure, return DEFAULT if supplied, otherwise return an empty matrix. (This function uses the code of Octaves 'optimget' function.)  File: database.info, Node: Documentation, Next: Postgresql, Prev: Setting options, Up: Top 6 Function database_doc to view documentation ********************************************* -- Function File: database_doc () -- Function File: database_doc (KEYWORD) Show database package documentation. Runs the info viewer Octave is configured with on the documentation in info format of the installed database package. Without argument, the top node of the documentation is displayed. With an argument, the respective index entry is searched for and its node displayed.  File: database.info, Node: Postgresql, Next: Function index, Prev: Documentation, Up: Top 7 Description of access to Postgresql databases *********************************************** * Menu: * Postgresql data types:: Representation in Octave of types specific to Postgresql. * Connection functions:: Functions related to the connection to a Postgresql database. * Data exchange:: Functions for data exchange with a Postgresql database. * Examples:: Examples for accessing Postgresql.  File: database.info, Node: Postgresql data types, Next: Connection functions, Up: Postgresql 7.1 Representation in Octave of types specific to Postgresql ============================================================ For the general types, defined by SQL and potentially available in each database implementation, *note SQL data types::. The last column indicates whether the SQL type is automatically deduced by this packages functions from the representation of the data in Octave. If not, the correct SQL type must be specified by the user if the data is sent from Octave to the database. Postgresql Octave auto ---------------------------------------------------------------- oid uint32 scalar yes text string yes name string of length < 'NAMEDATALEN' no (often 64) money int64 scalar, which is 100 times the no currency value to enable storing the 'small currency' (e.g. Cent) fraction in the last two digits point geometric point data for one point yes (see below) lseg geometric point data for two points yes (see below) line (not yet as lseg no implemented by postgresql-9.2.4) box as lseg no circle real vector (but the restrictions yes for type uint8 as in geometric element type apply, as explained below) with 3 elements, no. 1 and 2 centre coordinates, no. 3 radius polygon geometric point data (see below) no path structure with fields 'closed' no (boolean, is path closed?) and 'path' (geometric point data, see below). inet uint8 array of 4 or 5 elements for no IPv4 or uint16 array of 8 or 9 elements for IPv6. 5th or 9th element, respectively, contain number of set bits in network mask, the default (if there are only 4 or 8 elements, respectively) is all bits set. cidr as inet no macaddr uint8 array of 6 elements no uuid uint8 array of 16 elements no any enum type string no The 8-byte-time value (see time types in *note SQL data types::) can be an int64 scalar, representing microseconds, if the Postgresql server is configured for integer date/time, or a double scalar, representing seconds, if the server is configured for float date/time (deprecated). One can use *note pq_conninfo:: to query the respective server configuration. Geometric point data: if converting from Octave data, any real array (but if of type uint8, the geometric type name must always be specified, for otherwise uint8 would be considered as bytea) with even number of elements. Two adjacent elements (adjacent if indexed with a single index) define a pair of 2D point coordinates. In converting from Postgresql data, dimensions of Octave geometric point data will be chosen to be (2, n_points) and elements will be of format double.  File: database.info, Node: Connection functions, Next: Data exchange, Prev: Postgresql data types, Up: Postgresql 7.2 Functions related to the connection to a Postgresql database ================================================================ * Menu: * pq_connect:: Connecting to a Postgresql database. * pq_close:: Disconnecting from a Postgresql database. * pq_conninfo:: Retrieving information on the connection and on the server.  File: database.info, Node: pq_connect, Next: pq_close, Up: Connection functions 7.2.1 Connecting to a Postgresql database ----------------------------------------- -- Function File: CONNECTION = pq_connect (SETTINGS) Establishes a connection to a postgresql server according to SETTINGS and returns an 'octave_pq_connection' object CONNECTION which can be passed to other functions of the package. There can be multiple connections. An 'octave_pq_connection' object contains information on a connection and will be internally altered by the packages functions even though it is only passed as an argument, i.e. Octaves 'pass by value' semantics are not adhered to in this case. SETTINGS can be set by 'setdbopts' (copied from Octaves 'optimset') and can contain (defaults depend on Postgresql): 'host' (hostname), 'hostaddr' (numeric host address), 'port' (port to connect to), 'dbname' (database to connect to), 'user' (user name to connect as), 'password', 'connect_timeout', 'options' (command-line options to send to the server at run-time, see Postgresql documentation), 'sslmode' ('disable', 'allow', 'prefer', 'require', 'verify-ca', or 'verify-full'; see Postgresql documentation of SSL support), 'sslcert' (file name of client SSL certificate), 'sslkey' (location of secret key for client certificate, file name or external OpenSSL engine (colon-separated engine name and an engine-specific key identifier)), 'sslrootcert' (file name of root SSL certificate), 'sslcrl' (file name of SSL certificate revocation list), 'krbsrvname' (kerberos service name), 'service' (service name in pq_service.conf to use for additional parameters). All these settings are passed to the server as they are, so it may be better to consult the postgresql documentation for them, e.g. the documentation of the PQconnectdb function in libpq. See also: *note pq_exec_params: XREFpq_exec_params, *note pq_update_types: XREFpq_update_types.  File: database.info, Node: pq_close, Next: pq_conninfo, Prev: pq_connect, Up: Connection functions 7.2.2 Disconnecting from a Postgresql database ---------------------------------------------- -- Loadable Function: pq_close (CONNECTION) Closes connection CONNECTION to a postgresql server. See also: *note pq_connect: XREFpq_connect.  File: database.info, Node: pq_conninfo, Prev: pq_close, Up: Connection functions 7.2.3 Retrieving information on the connection and on the server ---------------------------------------------------------------- -- Loadable Function: VAL = pq_conninfo (CONNECTION, LABEL) Retrieves connection information for postgresql connection CONNECTION, specified by the string LABEL, and returns the value of this information in VAL. The type of VAL depends on the requested information. Currently, the only recognized LABEL is ''integer_datetimes''; VAL is 'true' if 8-byte date and time values are stored as integer in the server, and 'false' if they are stored as 'double' (which is deprecated).  File: database.info, Node: Data exchange, Next: Examples, Prev: Connection functions, Up: Postgresql 7.3 Functions for data exchange with a Postgresql database ========================================================== * Menu: * pq_exec_params:: Issuing SQL commands. * pq_update_types:: Updating type information. Large objects * pq_lo_import:: Importing large objects into a database. * pq_lo_export:: Exporting large objects from a database. * pq_lo_unlink:: Deleting large objects from a database. * pq_lo_view:: Viewing large objects.  File: database.info, Node: pq_exec_params, Next: pq_update_types, Up: Data exchange 7.3.1 Issuing SQL commands -------------------------- -- Function File: pq_exec_params (CONNECTION, COMMAND) -- Loadable Function: pq_exec_params (CONNECTION, COMMAND, PARAMS) -- Loadable Function: pq_exec_params (CONNECTION, COMMAND, SETTINGS) -- Loadable Function: pq_exec_params (CONNECTION, COMMAND, PARAMS, SETTINGS) Sends the string COMMAND, which must contain a single SQL command, over the connection CONNECTION. Parameters in COMMAND can be replaced by $1, $2, etc and their values given in the one-dimensional cell-array PARAMS. Parameters of composite type sent this way must have their type defined in the database. For typeconversions, the package maintains a notion of defined types, which should be refreshed with 'pq_update_types' if types are defined or dropped after establishing the connection, or if the schema search path changes. SETTINGS is a structure of settings, it can be created by 'setdbopts'. Settings currently understood by 'pq_exec_params': 'param_types' One-dimensional cell-array with type specifications for parameters in PARAMS. If present, must have the same length as PARAMS. Entries may be empty if no specification is necessary (see below). Type specifications are strings corresponding to the entries returned by 'SELECT typname FROM pg_type WHERE typarray != 0 OR typtype = 'c';', optionally having '[]' appended (without space) to indicate an array. Type specifications can be schema-qualified, otherwise they refer to the visible type with that name. 'copy_in_path, copy_out_path' Path to files at the client side for 'copy from stdin' and 'copy to stdout', respectively. 'copy_in_from_variable' Logical scalar, default 'false'. If 'true', 'copy from stdin' uses data from an Octave variable instead of from a file. 'copy_in_data' 2-dimensional cell-array with columns of suitable type (see below) - will be used instead of a file as data for 'copy from stdin' if 'copy_in_from_variable' is 'true'. 'copy_in_types' If some columns in 'copy_in_data' need a type specification (see below), 'copy_in_types' has to be set to a cell-array with type specifications, with an entry (possibly empty) for each column. 'copy_in_with_oids' If you want to copy in with oids when using data from an Octave variable, the first column of the data must contain the OIDs and 'copy_in_with_oids' has to be set to 'true' (default 'false'); 'with oids' should be specified together with 'copy from stdin' in the command, otherwise Postgresql will ignore the copied oids. There is no way to 'copy to stdout' into an Octave variable, but a 'select' command can be used for this purpose. 'copy from stdin' from an Octave variable is only supported in binary mode, so this has to be specified in the SQL command. The output depends on the type of command. * queries (commands potentially returning data): The output will be a structure with fields 'data' (containing a cell array with the data, columns correspond to returned database columns, rows correspond to returned tuples), 'columns' (containing the column headers), and 'types' (a structure-vector with the postgresql data types of the columns, subfields 'name' (string with typename), 'is_array' (boolean), 'is_composite' (boolean), 'is_enum' (boolean), and 'elements' (if 'is_composite == true', structure-vector of element types, containing fields corresponding to those of 'types')). * copy commands: Nothing is returned (this may change in the future). * other commands: The output will be the number of affected rows in the database. See also: *note pq_update_types: XREFpq_update_types, *note pq_conninfo: XREFpq_conninfo. Type mapping ------------ For the mapping of currently implemented Postgresql types to Octave types, *note Postgresql data types::.  File: database.info, Node: pq_update_types, Next: pq_lo_import, Prev: pq_exec_params, Up: Data exchange 7.3.2 Updating type information ------------------------------- -- Loadable Function: pq_update_types (CONNECTION) Updates information on existing postgresql types for CONNECTION. Use this before 'pq_exec_params' if types were created or dropped while the connection was already established or if the schema search path changed. A newly created connection will automatically retrieve this information at connection time.  File: database.info, Node: pq_lo_import, Next: pq_lo_export, Prev: pq_update_types, Up: Data exchange 7.3.3 Importing large objects into a database --------------------------------------------- -- Loadable Function: OID = pq_lo_import (CONNECTION, PATH) Imports the file in PATH on the client side as a large object into the database associated with CONNECTION and returns the Oid of the new large object. If PATH ends with a '|', it is take as a shell command whose output is piped into a large object.  File: database.info, Node: pq_lo_export, Next: pq_lo_unlink, Prev: pq_lo_import, Up: Data exchange 7.3.4 Exporting large objects from a database --------------------------------------------- -- Loadable Function: pq_lo_export (CONNECTION, OID, PATH) Exports the large object of Oid OID in the database associated with CONNECTION to the file PATH on the client side. If PATH starts with a '|', it is taken as a shell commant to pipe to.  File: database.info, Node: pq_lo_unlink, Next: pq_lo_view, Prev: pq_lo_export, Up: Data exchange 7.3.5 Deleting large objects from a database -------------------------------------------- -- Loadable Function: pq_lo_unlink (CONNECTION, OID) Removes the large object of Oid OID from the database associated with CONNECTION.  File: database.info, Node: pq_lo_view, Prev: pq_lo_unlink, Up: Data exchange 7.3.6 Viewing large objects --------------------------- -- Function File: pq_lo_view (CONNECTION, OID, VIEWER) Exports the large object of Oid OID in the database associated with CONNECTION to a temporary file and starts the program VIEWER in the background with the name of the temporary file as argument. The temporary file will be removed after termination of the viewer.  File: database.info, Node: Examples, Prev: Data exchange, Up: Postgresql 7.4 Examples for accessing Postgresql ===================================== The examples assume that there is a database named 'test' and you have the necessary rights to access it without password (probably the database is on a server at the local machine) as the default user, i.e. the user with the same name as your current operating system account. Each example contains code for cleaning up, but, for more clarity, the cleanup is not enforced with Octaves 'unwind_protect' or with an SQL transaction. If something goes wrong, you can drop the database 'test' - this should assure purging any created large objects. You can also type 'demo pq_connect' to access some demo code. But it is possibly more difficult to read. 'test pq_connect' runs some functionality tests. The preconditions (access to a database named 'test') are the same as for the code in the current section. * Menu: * Large objects:: Large objects. * Copy in:: Copy in from Octave variable. * Composite types:: Working with composite types.  File: database.info, Node: Large objects, Next: Copy in, Up: Examples 7.4.1 Large objects ------------------- # connect conn = pq_connect (setdbopts ("dbname", "test")); # create table to store large object oids pq_exec_params (conn, "create table programs (name text, image oid);") # start transaction, so we don't miss storing the oid pq_exec_params (conn, "begin;") # download image, pipe it to a large objects and note its oid # (you need `wget' to be installed) oid = pq_lo_import (conn, "wget -q -O - https://www.gnu.org/software/octave/img/example-mesh.svg |") # write oid and program name into the table pq_exec_params (conn, "insert into programs values ($1, $2);", {"Octave", oid}) # finish transaction pq_exec_params (conn, "commit;") # find and retrieve the oid searching for the program name foid = pq_exec_params (conn, "select image from programs where name = $1;", {"Octave"}).data{1} # view large object corresponding to found foid # (you need `eog' to be installed, or change to another program able to # display `.svg') pq_lo_view (conn, foid, "eog") # cleanup (we don't use `begin;' and `rollback;' since the # example should show an inner transaction instead) pq_lo_unlink (conn, oid); pq_exec_params (conn, "drop table programs;"); pq_close (conn);  File: database.info, Node: Copy in, Next: Composite types, Prev: Large objects, Up: Examples 7.4.2 Copy in from Octave variable ---------------------------------- # connect conn = pq_connect (setdbopts ("dbname", "test")); # create table pq_exec_params (conn, "create table testdata (a float8, b float8, label text);") # generate data in Octave data = horzcat (num2cell (reshape (linspace (3, 4, 10), [], 2)), {"a"; "b"; "c"; "d"; "e"}) # copy in to the table pq_exec_params (conn, "copy testdata from stdin with (format binary);", setdbopts ("copy_in_from_variable", true, "copy_in_data", data)) # retrieve the data from the table rdata = pq_exec_params (conn, "select * from testdata;").data # cleanup pq_exec_params (conn, "drop table testdata;"); pq_close (conn);  File: database.info, Node: Composite types, Prev: Copy in, Up: Examples 7.4.3 Working with composite types ---------------------------------- This is a more complicated example with nested composite types. # connect conn = pq_connect (setdbopts ("dbname", "test")); # create a first composite type, consisting of a boolean and an array of # booleans pq_exec_params (conn, "create type complex_bool_array_type as (b bool, ba bool[]);") # create a second composite type, consisting of a boolean and the first # composite type pq_exec_params (conn, "create type complex_complex_bool_array_type as (b bool, c complex_bool_array_type);") # create a table with one column, holding the second defined composite # type pq_exec_params (conn, "create table complex_complex_bool_array (a complex_complex_bool_array_type);") # to enable data exchange using the new types, update type infomation pq_update_types (conn); # construct a data element for an SQL array of booleans in Octave d_arr = cell2struct ({2; {true, false; true, true}}, {"ndims", "data"}) # construct a data element for the first defined composite type in # Octave d_c1 = {true; d_arr}; # construct a data element for the second defined composite type in # Octave d_c2 = {false; d_c1}; # insert the data element of the second composite type into the table; # note that in this case specification of the parameter type in # `param_types' is necessary pq_exec_params (conn, "insert into complex_complex_bool_array values ($1);", {d_c2}, setdbopts ("param_types", {"complex_complex_bool_array_type"})) # read contents of the table result = pq_exec_params (conn, "select * from complex_complex_bool_array"); # only for demonstration purpouses, verify that the read data matches # the element constructed in Octave; # for this, the field `lbounds' is deleted from the returned data # # note that the verification would not work if we had constructed the # data element with rows of cell-arrays instead of columns, which would # also have been possible rdata = result.data{1}; rdata{2}{2} = rmfield (rdata{2}{2}, "lbounds"); isequal (d_c2, rdata) # view returned column names result.columns # view returned type information result.types # cleanup pq_exec_params (conn, "drop table complex_complex_bool_array;") pq_exec_params (conn, "drop type complex_complex_bool_array_type;") pq_exec_params (conn, "drop type complex_bool_array_type;") pq_close (conn);  File: database.info, Node: Function index, Next: Concept index, Prev: Postgresql, Up: Top Index of functions in database ****************************** [index] * Menu: * bytea2var: bytea2var. (line 6) * database_doc: Documentation. (line 6) * getdbopts: getdbopts. (line 6) * pq_close: pq_close. (line 6) * pq_connect: pq_connect. (line 6) * pq_conninfo: pq_conninfo. (line 6) * pq_exec_params: pq_exec_params. (line 6) * pq_lo_export: pq_lo_export. (line 6) * pq_lo_import: pq_lo_import. (line 6) * pq_lo_unlink: pq_lo_unlink. (line 6) * pq_lo_view: pq_lo_view. (line 6) * pq_update_types: pq_update_types. (line 6) * setdbopts: setdbopts. (line 6) * var2bytea: var2bytea. (line 6)  File: database.info, Node: Concept index, Prev: Function index, Up: Top Concept index ************* [index] * Menu: * arbitrary Octave types: Arbitrary Octave types. (line 6) * data exchange, Postgresql: Data exchange. (line 6) * data types: SQL data types. (line 6) * data types <1>: Postgresql data types. (line 6) * database connection: Connection functions. (line 6) * documentation: Documentation. (line 6) * examples, postgresql: Examples. (line 6) * options: Setting options. (line 6) * postgresql: Postgresql. (line 6) * postgresql examples: Examples. (line 6)  Tag Table: Node: Top815 Node: Installation2564 Node: Concept3299 Node: SQL data types5050 Node: Arbitrary Octave types9603 Node: var2bytea10404 Ref: XREFvar2bytea10575 Node: bytea2var11530 Ref: XREFbytea2var11711 Node: Setting options11955 Node: setdbopts12373 Ref: XREFsetdbopts12569 Node: getdbopts13525 Ref: XREFgetdbopts13795 Node: Documentation14165 Ref: XREFdatabase_doc14356 Node: Postgresql14773 Node: Postgresql data types15453 Node: Connection functions18940 Node: pq_connect19461 Ref: XREFpq_connect19632 Node: pq_close21542 Ref: XREFpq_close21743 Node: pq_conninfo21897 Ref: XREFpq_conninfo22115 Node: Data exchange22631 Node: pq_exec_params23263 Ref: XREFpq_exec_params23408 Node: pq_update_types27650 Ref: XREFpq_update_types27826 Node: pq_lo_import28211 Ref: XREFpq_lo_import28413 Node: pq_lo_export28746 Ref: XREFpq_lo_export28945 Node: pq_lo_unlink29208 Ref: XREFpq_lo_unlink29403 Node: pq_lo_view29550 Ref: XREFpq_lo_view29690 Node: Examples30033 Node: Large objects31204 Node: Copy in32698 Node: Composite types33644 Node: Function index36388 Node: Concept index37592  End Tag Table database-2.4.4/PaxHeaders.8241/create-test-account.sh0000644000000000000000000000013213444726064017160 xustar0030 mtime=1553181748.468190812 30 atime=1553181748.468190812 30 ctime=1553181803.415144792 database-2.4.4/create-test-account.sh0000755000175000017500000000270413444726064017437 0ustar00olafolaf00000000000000#!/bin/sh ## This file is intended for package testers, to conveniently create ## an account and a test database in the local postgresql database ## cluster. Will su to root and then to user postgres. There may be a ## harmless warning that postgres can't cd to current directory. ## Register a local postgresql user name corresponding to the current ## system account name. Create a database 'test' owned by this ## user. If the user or the database already exist, postgresql will ## not recreate them, but notify you. If postgresql notifies you that ## database 'test' already exists, you may have to manually give the ## user 'create' priviledges on this database. su -c "su -c '(echo \"create role $USER;\"; echo \"create database test with owner = $USER;\") | psql template1' postgres"; ## For tests and demos to work, the local postgresql server has to be ## configured to trust local connections if the current system account ## name is equal to the requested postgresql user name. The following ## setting in /etc/postgresql//main/pg_hba.conf assures this: ## ## # TYPE DATABASE USER ADDRESS METHOD ## ## # "local" is for Unix domain socket connections only ## local all all peer ## ## ## see: ## ## https://www.postgresql.org/docs/9.4/static/auth-methods.html#AUTH-PEER ## ## This configuration is _not_ provided by the current script, but ## should be the default at many systems. database-2.4.4/PaxHeaders.8241/NEWS0000644000000000000000000000013213444726064013451 xustar0030 mtime=1553181748.464224151 30 atime=1553181748.464224151 30 ctime=1553181803.415144792 database-2.4.4/NEWS0000644000175000017500000000502713444726064013726 0ustar00olafolaf00000000000000database 2.4.4 -------------- ** Build fixes. Builds with Octave 5.1. ** Works now also with a postgresql server owned by a different user than postgres. datatase 2.4.3 -------------- ** Build fixes. Builds with Octave 4.4. datatase 2.4.2 -------------- ** Some build fixes. Builds with Octave 4.2. ** Some documentation fixes. Added installation hints to documentation. datatase 2.4.1 -------------- ** Fixed data corruption bug in var2bytea. database 2.4.0 -------------- ** Added general package documentation. ** New functions var2bytea and bytea2var, enabling storing Octave values of arbitrary type in a database. ** Compatible with Octaves new exception-based error handling. Compatibility with old error handling up to Octave-4.0 is retained. ** Fixed racing condition in pq_lo_view. ** Fix: remove autoloaded function at package unload. database 2.3.2 -------------- ** Fix a potential source of internal bugs. ** Incompatible versions of postgresql (< 8.3) are rejected at configure time. database 2.3.1 -------------- ** Fix for compilation for mxe-octave. database 2.3.0 -------------- ** New function pq_lo_view. database 2.2.0 -------------- ** pq_exec_params: For queries, information on postgresql data types of columns is also returned. ** Converters for all base types except text search types implemented. ** New function pq_conninfo. ** Fix for includes on Apple. database 2.1.1: --------------- ** Account for system-dependence of postgresql include directories. ** Work around problem with sequential addpath in 'pkg build'. database 2.1.0: --------------- ** pq_exec_params: An Octave cell-array can be used as data for 'copy from stdin'. database 2.0.1: --------------- ** Bugfix of random crash at initialization time. Initial release of new package database 2.0.0: ---------------------------------------------- ** This is a complete replacement of the former database package and is not compatible with previous releases. The current release only supports postgresql. ** Functions: pq_connect: connect to a postgresql database, pq_exec_params: execute an SQL command with optional parameters and return result, pq_update_types: used if defined types change during connection time, pq_lo_import: import large object from client side, pq_lo_export: export large object to client side, pq_lo_unlink: delete large object, pq_close: disconnect from database.